diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-27 13:47:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-27 13:47:22 +0000 |
commit | aba203f8b2d14db50d69b0f81f7d33e948f56308 (patch) | |
tree | 9d04cf532fc4fa86621cbb0b6da8be7183200dea /src/ats/perf_ats_solver.c | |
parent | b238cc48391682b2fee423f3cb4de1965eef1aaf (diff) | |
download | gnunet-aba203f8b2d14db50d69b0f81f7d33e948f56308.tar.gz gnunet-aba203f8b2d14db50d69b0f81f7d33e948f56308.zip |
added multiple iteration support for averaging
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r-- | src/ats/perf_ats_solver.c | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 88e5400c8..6c1f7abaf 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -110,9 +110,7 @@ struct PerfHandle | |||
110 | * */ | 110 | * */ |
111 | struct GNUNET_ATS_PluginEnvironment env; | 111 | struct GNUNET_ATS_PluginEnvironment env; |
112 | 112 | ||
113 | struct Result *head; | 113 | struct Iteration *iterations_results; |
114 | |||
115 | struct Result *tail; | ||
116 | 114 | ||
117 | struct Result *current_result; | 115 | struct Result *current_result; |
118 | 116 | ||
@@ -160,6 +158,16 @@ struct PerfHandle | |||
160 | int measure_updates; | 158 | int measure_updates; |
161 | 159 | ||
162 | /** | 160 | /** |
161 | * Number of iterations | ||
162 | */ | ||
163 | int iterations; | ||
164 | |||
165 | /** | ||
166 | * Current iteration | ||
167 | */ | ||
168 | int current_iteration; | ||
169 | |||
170 | /** | ||
163 | * Is a bulk operation running? | 171 | * Is a bulk operation running? |
164 | */ | 172 | */ |
165 | int bulk_running; | 173 | int bulk_running; |
@@ -170,6 +178,13 @@ struct PerfHandle | |||
170 | int expecting_solution; | 178 | int expecting_solution; |
171 | }; | 179 | }; |
172 | 180 | ||
181 | struct Iteration | ||
182 | { | ||
183 | struct Result *result_head; | ||
184 | |||
185 | struct Result *result_tail; | ||
186 | }; | ||
187 | |||
173 | struct Result | 188 | struct Result |
174 | { | 189 | { |
175 | struct Result *prev; | 190 | struct Result *prev; |
@@ -445,8 +460,8 @@ solver_info_cb (void *cls, | |||
445 | { | 460 | { |
446 | case GAS_OP_SOLVE_START: | 461 | case GAS_OP_SOLVE_START: |
447 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 462 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
448 | "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", | 463 | "Solver notifies `%s' with result `%s' `%s' in iteration %u \n", "GAS_OP_SOLVE_START", |
449 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); | 464 | (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info, ph.current_iteration); |
450 | if (GNUNET_NO == ph.expecting_solution) | 465 | if (GNUNET_NO == ph.expecting_solution) |
451 | { | 466 | { |
452 | /* We do not expect a solution at the moment */ | 467 | /* We do not expect a solution at the moment */ |
@@ -459,7 +474,8 @@ solver_info_cb (void *cls, | |||
459 | /* Create new result */ | 474 | /* Create new result */ |
460 | tmp = GNUNET_new (struct Result); | 475 | tmp = GNUNET_new (struct Result); |
461 | ph.current_result = tmp; | 476 | ph.current_result = tmp; |
462 | GNUNET_CONTAINER_DLL_insert_tail(ph.head, ph.tail, tmp); | 477 | GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head, |
478 | ph.iterations_results[ph.current_iteration-1].result_tail, tmp); | ||
463 | ph.current_result->addresses = ph.current_a; | 479 | ph.current_result->addresses = ph.current_a; |
464 | ph.current_result->peers = ph.current_p; | 480 | ph.current_result->peers = ph.current_p; |
465 | ph.current_result->s_total = GNUNET_TIME_absolute_get(); | 481 | ph.current_result->s_total = GNUNET_TIME_absolute_get(); |
@@ -681,9 +697,14 @@ write_gnuplot_script (char * data_fn, int full) | |||
681 | 697 | ||
682 | } | 698 | } |
683 | 699 | ||
700 | /** | ||
701 | * Evaluate results for a specific iteration | ||
702 | * | ||
703 | * @oaram iteration the iteration to evaluate | ||
704 | */ | ||
684 | 705 | ||
685 | static void | 706 | static void |
686 | evaluate () | 707 | evaluate (int iteration) |
687 | { | 708 | { |
688 | struct GNUNET_DISK_FileHandle *f_full; | 709 | struct GNUNET_DISK_FileHandle *f_full; |
689 | struct GNUNET_DISK_FileHandle *f_update; | 710 | struct GNUNET_DISK_FileHandle *f_update; |
@@ -754,7 +775,8 @@ evaluate () | |||
754 | write_gnuplot_script (data_fn_update, GNUNET_NO); | 775 | write_gnuplot_script (data_fn_update, GNUNET_NO); |
755 | } | 776 | } |
756 | 777 | ||
757 | next = ph.head; | 778 | |
779 | next = ph.iterations_results[ph.current_iteration -1].result_head; | ||
758 | while (NULL != (cur = next)) | 780 | while (NULL != (cur = next)) |
759 | { | 781 | { |
760 | next = cur->next; | 782 | next = cur->next; |
@@ -843,7 +865,8 @@ evaluate () | |||
843 | GNUNET_free_non_null (str_d_lp); | 865 | GNUNET_free_non_null (str_d_lp); |
844 | GNUNET_free_non_null (str_d_mlp); | 866 | GNUNET_free_non_null (str_d_mlp); |
845 | 867 | ||
846 | GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur); | 868 | GNUNET_CONTAINER_DLL_remove (ph.iterations_results[ph.current_iteration-1].result_head, |
869 | ph.iterations_results[ph.current_iteration-1].result_tail, cur); | ||
847 | GNUNET_free (cur); | 870 | GNUNET_free (cur); |
848 | } | 871 | } |
849 | 872 | ||
@@ -860,7 +883,7 @@ evaluate () | |||
860 | 883 | ||
861 | 884 | ||
862 | static void | 885 | static void |
863 | perf_run () | 886 | perf_run (void) |
864 | { | 887 | { |
865 | struct ATS_Address *cur; | 888 | struct ATS_Address *cur; |
866 | struct ATS_Address *next; | 889 | struct ATS_Address *next; |
@@ -872,11 +895,10 @@ perf_run () | |||
872 | 895 | ||
873 | 896 | ||
874 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); | 897 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); |
875 | |||
876 | for (cp = 0; cp < count_p; cp++) | 898 | for (cp = 0; cp < count_p; cp++) |
877 | perf_create_peer (cp); | 899 | perf_create_peer (cp); |
878 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 900 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
879 | "Added %u peers\n", cp); | 901 | "Iteration %u of %u, added %u peers\n", ph.current_iteration, ph.iterations, cp); |
880 | 902 | ||
881 | for (cp = 0; cp < count_p; cp++) | 903 | for (cp = 0; cp < count_p; cp++) |
882 | { | 904 | { |
@@ -963,8 +985,6 @@ perf_run () | |||
963 | 985 | ||
964 | } | 986 | } |
965 | GNUNET_free(ph.peers); | 987 | GNUNET_free(ph.peers); |
966 | |||
967 | evaluate (); | ||
968 | } | 988 | } |
969 | 989 | ||
970 | 990 | ||
@@ -1039,11 +1059,11 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1039 | ph.N_address = DEFAULT_ADDRESSES; | 1059 | ph.N_address = DEFAULT_ADDRESSES; |
1040 | 1060 | ||
1041 | if (ph.N_peers_start != ph.N_peers_end) | 1061 | if (ph.N_peers_start != ph.N_peers_end) |
1042 | fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses\n", | 1062 | fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses in %u iterations\n", |
1043 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 1063 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, ph.iterations); |
1044 | else | 1064 | else |
1045 | fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses\n", | 1065 | fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses in %u iterations\n", |
1046 | ph.ats_string, ph.N_peers_end, ph.N_address); | 1066 | ph.ats_string, ph.N_peers_end, ph.N_address, ph.iterations); |
1047 | 1067 | ||
1048 | if (0 == ph.opt_update_percent) | 1068 | if (0 == ph.opt_update_percent) |
1049 | ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE; | 1069 | ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE; |
@@ -1064,6 +1084,9 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1064 | return; | 1084 | return; |
1065 | } | 1085 | } |
1066 | 1086 | ||
1087 | /* Create array of DLL to store results for iterations */ | ||
1088 | ph.iterations_results = GNUNET_malloc (sizeof (struct Iteration) * ph.iterations); | ||
1089 | |||
1067 | /* Load solver */ | 1090 | /* Load solver */ |
1068 | ph.env.cfg = solver_cfg; | 1091 | ph.env.cfg = solver_cfg; |
1069 | ph.stat = GNUNET_STATISTICS_create ("ats", cfg); | 1092 | ph.stat = GNUNET_STATISTICS_create ("ats", cfg); |
@@ -1099,8 +1122,12 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
1099 | return; | 1122 | return; |
1100 | } | 1123 | } |
1101 | 1124 | ||
1102 | /* Do work */ | 1125 | /* Do the benchmark */ |
1103 | perf_run (); | 1126 | for (ph.current_iteration = 1; ph.current_iteration <= ph.iterations; ph.current_iteration++) |
1127 | { | ||
1128 | perf_run (); | ||
1129 | evaluate (ph.current_iteration); | ||
1130 | } | ||
1104 | 1131 | ||
1105 | /* Unload solver*/ | 1132 | /* Unload solver*/ |
1106 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string); | 1133 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string); |
@@ -1122,6 +1149,7 @@ main (int argc, char *argv[]) | |||
1122 | ph.ats_string = NULL; | 1149 | ph.ats_string = NULL; |
1123 | ph.create_plot = GNUNET_NO; | 1150 | ph.create_plot = GNUNET_NO; |
1124 | ph.measure_updates = GNUNET_NO; | 1151 | ph.measure_updates = GNUNET_NO; |
1152 | ph.iterations = 1; | ||
1125 | 1153 | ||
1126 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 1154 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
1127 | { 'a', "addresses", NULL, | 1155 | { 'a', "addresses", NULL, |
@@ -1133,6 +1161,9 @@ main (int argc, char *argv[]) | |||
1133 | { 'e', "end", NULL, | 1161 | { 'e', "end", NULL, |
1134 | gettext_noop ("end with peer"), | 1162 | gettext_noop ("end with peer"), |
1135 | 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end }, | 1163 | 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end }, |
1164 | { 'i', "iterations", NULL, | ||
1165 | gettext_noop ("number of iterations used for averaging (default: 1)"), | ||
1166 | 1, &GNUNET_GETOPT_set_uint, &ph.iterations }, | ||
1136 | { 'p', "percentage", NULL, | 1167 | { 'p', "percentage", NULL, |
1137 | gettext_noop ("update a fix percentage of addresses"), | 1168 | gettext_noop ("update a fix percentage of addresses"), |
1138 | 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, | 1169 | 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, |