aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-04-15 11:47:58 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-04-15 11:47:58 +0000
commit082a4ab779c24b591e2de1628805d7d36f0051bc (patch)
tree83a4032a26d8ff48e8b7fb2c92fec5f7ae639e39 /src/transport
parent02b8a113a9f6ef38b567cbfe52fc70c6a61437a7 (diff)
downloadgnunet-082a4ab779c24b591e2de1628805d7d36f0051bc.tar.gz
gnunet-082a4ab779c24b591e2de1628805d7d36f0051bc.zip
improvements for better benchmarking
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c53
-rw-r--r--src/transport/test_transport_ats.c121
2 files changed, 114 insertions, 60 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index a74ea114e..e3d5054b4 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -6062,23 +6062,6 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig
6062 /* done */ 6062 /* done */
6063 } 6063 }
6064 6064
6065 if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1))
6066 {
6067 char * filename;
6068 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value);
6069 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6070 glp_write_lp (prob, NULL, filename);
6071 GNUNET_free (filename);
6072 }
6073 if ((ats->save_solution == GNUNET_YES) && (c_peers > 1))
6074 {
6075 char * filename;
6076 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value);
6077 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6078 glp_print_sol (prob, filename);
6079 GNUNET_free (filename);
6080 }
6081
6082 /* 6065 /*
6083 int check; 6066 int check;
6084 int error = GNUNET_NO; 6067 int error = GNUNET_NO;
@@ -6774,6 +6757,7 @@ ats_calculate_bandwidth_distribution ()
6774 struct GNUNET_TIME_Absolute start; 6757 struct GNUNET_TIME_Absolute start;
6775 struct GNUNET_TIME_Relative creation; 6758 struct GNUNET_TIME_Relative creation;
6776 struct GNUNET_TIME_Relative solving; 6759 struct GNUNET_TIME_Relative solving;
6760 char *text = "unmodified";
6777 6761
6778 struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); 6762 struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get());
6779 if (delta.rel_value < ats->min_delta.rel_value) 6763 if (delta.rel_value < ats->min_delta.rel_value)
@@ -6793,19 +6777,22 @@ ats_calculate_bandwidth_distribution ()
6793 start = GNUNET_TIME_absolute_get(); 6777 start = GNUNET_TIME_absolute_get();
6794 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) 6778 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL))
6795 { 6779 {
6780 text = "new";
6796 ats_delete_problem (); 6781 ats_delete_problem ();
6797 ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat); 6782 ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat);
6798#if DEBUG_ATS 6783#if DEBUG_ATS
6799 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, ats->stat.c_mechs); 6784 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, ats->stat.c_mechs);
6800#endif 6785#endif
6801 } 6786 }
6802 else if (ats->modified_resources == GNUNET_YES) 6787 else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_resources == GNUNET_YES))
6803 { 6788 {
6804 ats_update_problem_cr(); 6789 ats_update_problem_cr();
6790 text = "modified resources";
6805 } 6791 }
6806 else if (ats->modified_quality == GNUNET_YES) 6792 else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_quality == GNUNET_YES))
6807 { 6793 {
6808 ats_update_problem_qm(); 6794 ats_update_problem_qm();
6795 text = "modified quality";
6809 } 6796 }
6810#if DEBUG_ATS 6797#if DEBUG_ATS
6811 else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); 6798 else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n");
@@ -6818,8 +6805,8 @@ ats_calculate_bandwidth_distribution ()
6818 { 6805 {
6819 ats->stat.solution = GNUNET_SYSERR; 6806 ats->stat.solution = GNUNET_SYSERR;
6820 ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat); 6807 ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat);
6821 if (ats->stat.solution != 5) 6808 //if (ats->stat.solution != 5)
6822 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution is not optimal: %i\n", ats->stat.solution); 6809 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution is not optimal: %i\n", ats->stat.solution);
6823 } 6810 }
6824 6811
6825 solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 6812 solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
@@ -6827,7 +6814,11 @@ ats_calculate_bandwidth_distribution ()
6827 if (ats->stat.valid == GNUNET_YES) 6814 if (ats->stat.valid == GNUNET_YES)
6828 { 6815 {
6829#if DEBUG_ATS 6816#if DEBUG_ATS
6830 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP: creation time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", creation.rel_value, solving.rel_value, ats->stat.c_mechs); 6817
6818 //if (ats->stat.c_peers > 1)
6819 //{
6820 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP %s: creation time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", text, creation.rel_value, solving.rel_value, ats->stat.c_mechs);
6821 //}
6831#endif 6822#endif
6832 GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); 6823 GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
6833 GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO); 6824 GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO);
@@ -6852,6 +6843,24 @@ ats_calculate_bandwidth_distribution ()
6852 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n"); 6843 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n");
6853 } 6844 }
6854#endif 6845#endif
6846
6847 if ((ats->save_mlp == GNUNET_YES) && (ats->stat.c_peers > 1))
6848 {
6849 char * filename;
6850 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
6851 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6852 glp_write_lp (ats->prob, NULL, filename);
6853 GNUNET_free (filename);
6854 }
6855 if ((ats->save_solution == GNUNET_YES) && (ats->stat.c_peers > 1))
6856 {
6857 char * filename;
6858 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol", ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
6859 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6860 glp_print_sol (ats->prob, filename);
6861 GNUNET_free (filename);
6862 }
6863
6855 ats->last = GNUNET_TIME_absolute_get(); 6864 ats->last = GNUNET_TIME_absolute_get();
6856 6865
6857 ats->modified_addr = GNUNET_NO; 6866 ats->modified_addr = GNUNET_NO;
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index e83080a1a..27c0b65f5 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -49,6 +49,7 @@ static int peers_left;
49static int failed_peers; 49static int failed_peers;
50 50
51static int measurement_started = GNUNET_NO; 51static int measurement_started = GNUNET_NO;
52static char * config_file;
52 53
53static struct GNUNET_TESTING_PeerGroup *pg; 54static struct GNUNET_TESTING_PeerGroup *pg;
54 55
@@ -87,6 +88,7 @@ static int peers;
87static int force_q_updates; 88static int force_q_updates;
88static int force_rebuild; 89static int force_rebuild;
89static int send_msg; 90static int send_msg;
91static int machine_parsable;
90 92
91static struct TEST_result results_new [MEASUREMENTS+1]; 93static struct TEST_result results_new [MEASUREMENTS+1];
92static struct TEST_result results_modified [MEASUREMENTS+1]; 94static struct TEST_result results_modified [MEASUREMENTS+1];
@@ -198,62 +200,74 @@ static void shutdown_peers()
198static void evaluate_measurements() 200static void evaluate_measurements()
199{ 201{
200 int c; 202 int c;
201 double average ; 203 //int mechs = 0;
202 double stddev; 204 double average[3];
203 205 double stddev[3];
206 //char * output;
204 c = 1; 207 c = 1;
205 208
206 average = 0.0; 209 //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs,
210
211 average[0] = 0.0;
207 for (c=0; c<c_new;c++) 212 for (c=0; c<c_new;c++)
208 { 213 {
209 average += (double) results_new[c].duration; 214 average[0] += (double) results_new[c].duration;
210 } 215 }
211 average /= c_new; 216 average[0] /= c_new;
212 217
213 stddev = 0.0; 218 stddev[0] = 0.0;
214 for (c=0; c<c_new;c++) 219 for (c=0; c<c_new;c++)
215 { 220 {
216 stddev += (results_new[c].duration - average) * (results_new[c].duration - average); 221 stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]);
217 } 222 }
218 stddev /= c_new; 223 stddev[0] /= c_new;
219 stddev = sqrt (stddev); 224 stddev[0] = sqrt (stddev[0]);
220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new average: %f stddev: %f\n", average, stddev); 225 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new, %i measurements, average: %f stddev: %f\n",
226 c_new, average[0], stddev[0]);
221 227
222 average = 0.0; 228 average[1] = 0.0;
223 for (c=0; c<c_modified;c++) 229 for (c=0; c<c_modified;c++)
224 { 230 {
225 average += (double) results_modified[c].duration; 231 average[1] += (double) results_modified[c].duration;
226 } 232 }
227 average /= c_modified; 233 average[1] /= c_modified;
228 234
229 stddev = 0.0; 235 stddev[1] = 0.0;
230 for (c=0; c<c_modified;c++) 236 for (c=0; c<c_modified;c++)
231 { 237 {
232 stddev += (results_modified[c].duration - average) * (results_modified[c].duration - average); 238 stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]);
233 } 239 }
234 stddev /= c_modified; 240 stddev[1] /= c_modified;
235 stddev = sqrt (stddev); 241 stddev[1] = sqrt (stddev[1]);
236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified average: %f stddev: %f\n", average, stddev); 242 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified, %i measurements, average: %f stddev: %f\n",
243 c_modified, average[1], stddev[1]);
237 244
238 average = 0.0; 245 average[2] = 0.0;
239 for (c=0; c<c_unmodified;c++) 246 for (c=0; c<c_unmodified;c++)
240 { 247 {
241 average += (double) results_unmodified[c].duration; 248 average[2] += (double) results_unmodified[c].duration;
242 } 249 }
243 average /= c_unmodified; 250 average[2] /= c_unmodified;
244 stddev = 0.0; 251 stddev[2] = 0.0;
245 for (c=0; c<c_unmodified;c++) 252 for (c=0; c<c_unmodified;c++)
246 { 253 {
247 stddev += (results_unmodified[c].duration - average) * (results_unmodified[c].duration - average); 254 stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]);
248 } 255 }
249 stddev /= c_unmodified; 256 stddev[2] /= c_unmodified;
250 stddev = sqrt (stddev); 257 stddev[2] = sqrt (stddev[2]);
251 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified average: %f stddev: %f\n", average, stddev); 258
252 259 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified, %i measurements, average: %f stddev: %f\n",
253 260 c_unmodified, average[2], stddev[2]);
254 261
255 262 if (machine_parsable)
256 263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,",peers,%i,mechs,%i,"
264 "new,%i,%f,%f,"
265 "mod,%i,%f,%f,"
266 "unmod,%i,%f,%f\n",
267 peers-1, results_unmodified[0].mechs,
268 c_new, average[0], stddev[0],
269 c_modified, average[1], stddev[1],
270 c_unmodified, average[2], stddev[2]);
257 shutdown_peers(); 271 shutdown_peers();
258} 272}
259 273
@@ -310,6 +324,9 @@ int stats_cb (void *cls,
310 measurement_started = GNUNET_YES; 324 measurement_started = GNUNET_YES;
311 count = 1; 325 count = 1;
312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); 326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value);
327#if !VERBOSE
328 if (!machine_parsable) fprintf(stderr, "%i", count);
329#endif
313 } 330 }
314 331
315 if (measurement_started == GNUNET_YES) 332 if (measurement_started == GNUNET_YES)
@@ -367,9 +384,11 @@ int stats_cb (void *cls,
367 count ++; 384 count ++;
368 385
369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , MEASUREMENTS); 386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , MEASUREMENTS);
370 if ((count > MEASUREMENTS * 4) || ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))) 387 if ((count > MEASUREMENTS * 5) || ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)))
371 { 388 {
372 fprintf(stdout, "\n"); 389#if !VERBOSE
390 if (!machine_parsable) fprintf(stdout, "\n");
391#endif
373 if (stats_task != GNUNET_SCHEDULER_NO_TASK) 392 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
374 { 393 {
375 GNUNET_SCHEDULER_cancel(stats_task); 394 GNUNET_SCHEDULER_cancel(stats_task);
@@ -381,6 +400,9 @@ int stats_cb (void *cls,
381 400
382 printed = GNUNET_NO; 401 printed = GNUNET_NO;
383 current.timestamp = value; 402 current.timestamp = value;
403#if !VERBOSE
404 if (!machine_parsable) fprintf(stderr, "..%i", count);
405#endif
384 return GNUNET_OK; 406 return GNUNET_OK;
385 } 407 }
386 } 408 }
@@ -628,7 +650,7 @@ check ()
628{ 650{
629 char *const argv[] = { "test-testing", 651 char *const argv[] = { "test-testing",
630 "-c", 652 "-c",
631 "test_transport_ats.conf", 653 config_file,
632#if VERBOSE 654#if VERBOSE
633 "-L", "DEBUG", 655 "-L", "DEBUG",
634#endif 656#endif
@@ -662,13 +684,36 @@ main (int argc, char *argv[])
662 NULL); 684 NULL);
663 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); 685 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
664 686
687 machine_parsable = GNUNET_NO;
665 peers = NUM_PEERS; 688 peers = NUM_PEERS;
666 if (argc == 2) 689 config_file = "test_transport_ats_1addr.conf";
690
691 int c = 0;
692 if (argc >= 2)
667 { 693 {
668 peers = atoi(argv[1]); 694 for (c=0; c<argc; c++)
669 peers++; 695 {
696 /* set peers */
697 if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
698 {
699 peers = atoi(argv[c+1]);
700 peers++;
701 }
702 /* set machine parsable */
703 if (strcmp(argv[c], "-m") == 0)
704 {
705 machine_parsable = GNUNET_YES;
706 }
707 /* set config file */
708 if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
709 {
710 config_file = argv[c+1];
711 }
712 }
670 } 713 }
671 714
715
716
672 ret = check (); 717 ret = check ();
673 /** 718 /**
674 * Still need to remove the base testing directory here, 719 * Still need to remove the base testing directory here,