diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-31 16:25:15 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-31 16:25:15 +0000 |
commit | da5c12170ab8ffa5d91a9e704a7060b79ce465fd (patch) | |
tree | 5623457c0d5760e908f0aedde972116c6c36ade7 /src/ats/perf_ats_solver.c | |
parent | ccca2c88edefc822d4e8e4b81403448d14e29070 (diff) | |
download | gnunet-da5c12170ab8ffa5d91a9e704a7060b79ce465fd.tar.gz gnunet-da5c12170ab8ffa5d91a9e704a7060b79ce465fd.zip |
benchmark with updates
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r-- | src/ats/perf_ats_solver.c | 274 |
1 files changed, 183 insertions, 91 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 0b0fbb1b8..ddb16fe5f 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "gnunet_ats_plugin.h" | 32 | #include "gnunet_ats_plugin.h" |
33 | #include "test_ats_api_common.h" | 33 | #include "test_ats_api_common.h" |
34 | 34 | ||
35 | #define DEFAULT_UPDATE_PERCENTAGE 20 | ||
35 | #define DEFAULT_PEERS_START 10 | 36 | #define DEFAULT_PEERS_START 10 |
36 | #define DEFAULT_PEERS_END 10 | 37 | #define DEFAULT_PEERS_END 10 |
37 | #define DEFAULT_ADDRESSES 10 | 38 | #define DEFAULT_ADDRESSES 10 |
@@ -44,6 +45,13 @@ | |||
44 | "set ylabel \"Execution time in us\" \n" \ | 45 | "set ylabel \"Execution time in us\" \n" \ |
45 | "set grid \n" | 46 | "set grid \n" |
46 | 47 | ||
48 | #define GNUPLOT_PROP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
49 | "set datafile separator ';' \n" \ | ||
50 | "set title \"Execution time Proportional solver with updated problem\" \n" \ | ||
51 | "set xlabel \"Number of peers\" \n" \ | ||
52 | "set ylabel \"Execution time in us\" \n" \ | ||
53 | "set grid \n" | ||
54 | |||
47 | #define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 55 | #define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
48 | "set datafile separator ';' \n" \ | 56 | "set datafile separator ';' \n" \ |
49 | "set title \"Execution time MLP solver \" \n" \ | 57 | "set title \"Execution time MLP solver \" \n" \ |
@@ -51,6 +59,13 @@ | |||
51 | "set ylabel \"Execution time in us\" \n" \ | 59 | "set ylabel \"Execution time in us\" \n" \ |
52 | "set grid \n" | 60 | "set grid \n" |
53 | 61 | ||
62 | #define GNUPLOT_MLP_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
63 | "set datafile separator ';' \n" \ | ||
64 | "set title \"Execution time MLP solver with updated problem\" \n" \ | ||
65 | "set xlabel \"Number of peers\" \n" \ | ||
66 | "set ylabel \"Execution time in us\" \n" \ | ||
67 | "set grid \n" | ||
68 | |||
54 | #define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 69 | #define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
55 | "set datafile separator ';' \n" \ | 70 | "set datafile separator ';' \n" \ |
56 | "set title \"Execution time RIL solver \" \n" \ | 71 | "set title \"Execution time RIL solver \" \n" \ |
@@ -58,6 +73,13 @@ | |||
58 | "set ylabel \"Execution time in us\" \n" \ | 73 | "set ylabel \"Execution time in us\" \n" \ |
59 | "set grid \n" | 74 | "set grid \n" |
60 | 75 | ||
76 | #define GNUPLOT_RIL_UPDATE_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
77 | "set datafile separator ';' \n" \ | ||
78 | "set title \"Execution time RIL solver with updated problem\" \n" \ | ||
79 | "set xlabel \"Number of peers\" \n" \ | ||
80 | "set ylabel \"Execution time in us\" \n" \ | ||
81 | "set grid \n" | ||
82 | |||
61 | /** | 83 | /** |
62 | * Handle for ATS address component | 84 | * Handle for ATS address component |
63 | */ | 85 | */ |
@@ -128,14 +150,14 @@ struct PerfHandle | |||
128 | int opt_update_percent; | 150 | int opt_update_percent; |
129 | 151 | ||
130 | /** | 152 | /** |
131 | * Number of peers to update | 153 | * Create gnuplot file |
132 | */ | 154 | */ |
133 | int opt_update_quantity; | 155 | int create_plot; |
134 | 156 | ||
135 | /** | 157 | /** |
136 | * Create gnuplot file | 158 | * Measure updates |
137 | */ | 159 | */ |
138 | int create_plot; | 160 | int measure_updates; |
139 | 161 | ||
140 | /** | 162 | /** |
141 | * Is a bulk operation running? | 163 | * Is a bulk operation running? |
@@ -155,6 +177,7 @@ struct Result | |||
155 | 177 | ||
156 | int peers; | 178 | int peers; |
157 | int addresses; | 179 | int addresses; |
180 | int update; | ||
158 | 181 | ||
159 | enum GAS_Solver_Additional_Information info; | 182 | enum GAS_Solver_Additional_Information info; |
160 | 183 | ||
@@ -244,7 +267,7 @@ perf_update_address (struct ATS_Address *cur) | |||
244 | { | 267 | { |
245 | case 0: | 268 | case 0: |
246 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 269 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
247 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
248 | "Updating peer `%s' address %p type %s val %u\n", | 271 | "Updating peer `%s' address %p type %s val %u\n", |
249 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val); | 272 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val); |
250 | ph.env.sf.s_address_update_property (ph.solver, cur, | 273 | ph.env.sf.s_address_update_property (ph.solver, cur, |
@@ -254,7 +277,7 @@ perf_update_address (struct ATS_Address *cur) | |||
254 | case 1: | 277 | case 1: |
255 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); | 278 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); |
256 | 279 | ||
257 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 280 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
258 | "Updating peer `%s' address %p type %s val %u\n", | 281 | "Updating peer `%s' address %p type %s val %u\n", |
259 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); | 282 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); |
260 | ph.env.sf.s_address_update_property (ph.solver, cur, | 283 | ph.env.sf.s_address_update_property (ph.solver, cur, |
@@ -324,41 +347,53 @@ perf_address_initial_update (void *solver, | |||
324 | } | 347 | } |
325 | 348 | ||
326 | static void | 349 | static void |
327 | perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int up_q) | 350 | perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers) |
328 | { | 351 | { |
329 | struct ATS_Address *cur; | 352 | struct ATS_Address *cur_address; |
330 | int c_peer; | 353 | int c_peer; |
331 | int c_select; | 354 | int c_select; |
332 | int c_addr; | 355 | int c_cur_p; |
356 | int c_cur_a; | ||
333 | int r; | 357 | int r; |
358 | int count; | ||
359 | unsigned int m[cp]; | ||
334 | 360 | ||
335 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 361 | count = cp * ((double) percentage_peers / 100); |
336 | "Updating addresses %u addresses per peer \n", up_q); | 362 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
337 | unsigned int m[ca]; | 363 | "Updating %u of %u peers \n", count, cp); |
338 | 364 | ||
339 | for (c_peer = 0; c_peer < cp; c_peer++) | 365 | for (c_peer = 0; c_peer < cp; c_peer++) |
366 | m[c_peer] = 0; | ||
367 | |||
368 | c_select = 0; | ||
369 | |||
370 | while (c_select < count) | ||
371 | { | ||
372 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, cp); | ||
373 | if (0 == m[r]) | ||
374 | { | ||
375 | m[r] = 1; | ||
376 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
377 | "Updating peer [%u] \n", r); | ||
378 | c_select++; | ||
379 | } | ||
380 | } | ||
381 | for (c_cur_p = 0; c_cur_p < cp; c_cur_p++) | ||
340 | { | 382 | { |
341 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s'\n", | 383 | if (1 == m[c_cur_p]) |
342 | GNUNET_i2s (&ph.peers[c_peer].id)); | ||
343 | for (c_select = 0; c_select < ca; c_select++) | ||
344 | m[c_select] = 0; | ||
345 | c_select = 0; | ||
346 | while (c_select < ph.opt_update_quantity) | ||
347 | { | 384 | { |
348 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca); | 385 | r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca); |
349 | if (0 == m[r]) | 386 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
387 | "Updating peer [%u] address [%u]\n", c_cur_p, r); | ||
388 | |||
389 | c_cur_a = 0; | ||
390 | for (cur_address = ph.peers[c_cur_p].head; NULL != cur_address; cur_address = cur_address->next) | ||
350 | { | 391 | { |
351 | m[r] = 1; | 392 | if (c_cur_a == r) |
352 | c_select++; | 393 | perf_update_address (cur_address); |
353 | } | ||
354 | } | ||
355 | 394 | ||
356 | c_addr = 0; | 395 | c_cur_a ++; |
357 | for (cur = ph.peers[c_peer].head; NULL != cur; cur = cur->next) | 396 | } |
358 | { | ||
359 | if (1 == m[c_addr]) | ||
360 | perf_update_address (cur); | ||
361 | c_addr++; | ||
362 | } | 397 | } |
363 | } | 398 | } |
364 | } | 399 | } |
@@ -387,10 +422,10 @@ solver_info_cb (void *cls, | |||
387 | case GAS_INFO_NONE: | 422 | case GAS_INFO_NONE: |
388 | add_info = "GAS_INFO_NONE"; | 423 | add_info = "GAS_INFO_NONE"; |
389 | break; | 424 | break; |
390 | case GAS_INFO_MLP_FULL: | 425 | case GAS_INFO_FULL: |
391 | add_info = "GAS_INFO_MLP_FULL"; | 426 | add_info = "GAS_INFO_MLP_FULL"; |
392 | break; | 427 | break; |
393 | case GAS_INFO_MLP_UPDATED: | 428 | case GAS_INFO_UPDATED: |
394 | add_info = "GAS_INFO_MLP_UPDATED"; | 429 | add_info = "GAS_INFO_MLP_UPDATED"; |
395 | break; | 430 | break; |
396 | case GAS_INFO_PROP_ALL: | 431 | case GAS_INFO_PROP_ALL: |
@@ -431,6 +466,10 @@ solver_info_cb (void *cls, | |||
431 | ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL; | 466 | ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL; |
432 | ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL; | 467 | ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL; |
433 | ph.current_result->info = add; | 468 | ph.current_result->info = add; |
469 | if (add == GAS_INFO_UPDATED) | ||
470 | ph.current_result->update = GNUNET_YES; | ||
471 | else | ||
472 | ph.current_result->update = GNUNET_NO; | ||
434 | } | 473 | } |
435 | return; | 474 | return; |
436 | case GAS_OP_SOLVE_STOP: | 475 | case GAS_OP_SOLVE_STOP: |
@@ -526,7 +565,7 @@ solver_info_cb (void *cls, | |||
526 | } | 565 | } |
527 | ph.current_result->e_mlp = GNUNET_TIME_absolute_get (); | 566 | ph.current_result->e_mlp = GNUNET_TIME_absolute_get (); |
528 | ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference ( | 567 | ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference ( |
529 | ph.current_result->s_mlp, ph.current_result->e_mlp); | 568 | ph.current_result->s_mlp, ph.current_result->e_mlp); |
530 | return; | 569 | return; |
531 | 570 | ||
532 | default: | 571 | default: |
@@ -535,14 +574,17 @@ solver_info_cb (void *cls, | |||
535 | } | 574 | } |
536 | 575 | ||
537 | static void | 576 | static void |
538 | write_gnuplot_script (char * data_fn) | 577 | write_gnuplot_script (char * data_fn, int full) |
539 | { | 578 | { |
540 | struct GNUNET_DISK_FileHandle *f; | 579 | struct GNUNET_DISK_FileHandle *f; |
541 | char * gfn; | 580 | char * gfn; |
542 | char *data; | 581 | char *data; |
543 | char *template; | 582 | char *template; |
583 | if (GNUNET_YES == full) | ||
584 | GNUNET_asprintf (&gfn, "perf_%s_full_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | ||
585 | else | ||
586 | GNUNET_asprintf (&gfn, "perf_%s_update_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | ||
544 | 587 | ||
545 | GNUNET_asprintf (&gfn, "perf_%s_%u_%u_%u.gnuplot", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | ||
546 | f = GNUNET_DISK_file_open (gfn, | 588 | f = GNUNET_DISK_file_open (gfn, |
547 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 589 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
548 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 590 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
@@ -556,13 +598,22 @@ write_gnuplot_script (char * data_fn) | |||
556 | /* Write header */ | 598 | /* Write header */ |
557 | switch (ph.ats_mode) { | 599 | switch (ph.ats_mode) { |
558 | case MODE_PROPORTIONAL: | 600 | case MODE_PROPORTIONAL: |
559 | template = GNUPLOT_PROP_TEMPLATE; | 601 | if (GNUNET_YES == full) |
602 | template = GNUPLOT_PROP_TEMPLATE; | ||
603 | else | ||
604 | template = GNUPLOT_PROP_UPDATE_TEMPLATE; | ||
560 | break; | 605 | break; |
561 | case MODE_MLP: | 606 | case MODE_MLP: |
562 | template = GNUPLOT_MLP_TEMPLATE; | 607 | if (GNUNET_YES == full) |
608 | template = GNUPLOT_MLP_TEMPLATE; | ||
609 | else | ||
610 | template = GNUPLOT_MLP_UPDATE_TEMPLATE; | ||
563 | break; | 611 | break; |
564 | case MODE_RIL: | 612 | case MODE_RIL: |
565 | template = GNUPLOT_RIL_TEMPLATE; | 613 | if (GNUNET_YES == full) |
614 | template = GNUPLOT_RIL_TEMPLATE; | ||
615 | else | ||
616 | template = GNUPLOT_RIL_UPDATE_TEMPLATE; | ||
566 | break; | 617 | break; |
567 | default: | 618 | default: |
568 | break; | 619 | break; |
@@ -611,8 +662,10 @@ write_gnuplot_script (char * data_fn) | |||
611 | static void | 662 | static void |
612 | evaluate () | 663 | evaluate () |
613 | { | 664 | { |
614 | struct GNUNET_DISK_FileHandle *f; | 665 | struct GNUNET_DISK_FileHandle *f_full; |
615 | char * data_fn; | 666 | struct GNUNET_DISK_FileHandle *f_update; |
667 | char * data_fn_full; | ||
668 | char * data_fn_update; | ||
616 | char * data; | 669 | char * data; |
617 | struct Result *cur; | 670 | struct Result *cur; |
618 | struct Result *next; | 671 | struct Result *next; |
@@ -623,30 +676,52 @@ evaluate () | |||
623 | 676 | ||
624 | if (ph.create_plot) | 677 | if (ph.create_plot) |
625 | { | 678 | { |
626 | GNUNET_asprintf (&data_fn, "perf_%s_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 679 | GNUNET_asprintf (&data_fn_full, "perf_%s_full_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); |
627 | f = GNUNET_DISK_file_open (data_fn, | 680 | f_full = GNUNET_DISK_file_open (data_fn_full, |
628 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 681 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
629 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 682 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
630 | if (NULL == f) | 683 | if (NULL == f_full) |
631 | { | 684 | { |
632 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn); | 685 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_full); |
633 | return; | 686 | return; |
634 | } | 687 | } |
635 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | 688 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; |
636 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 689 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) |
637 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn); | 690 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full); |
638 | write_gnuplot_script (data_fn); | 691 | write_gnuplot_script (data_fn_full, GNUNET_YES); |
692 | |||
693 | } | ||
694 | if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) | ||
695 | { | ||
696 | GNUNET_asprintf (&data_fn_update, "perf_%s_update_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | ||
697 | f_update = GNUNET_DISK_file_open (data_fn_update, | ||
698 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
699 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
700 | if (NULL == f_update) | ||
701 | { | ||
702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_update); | ||
703 | return; | ||
704 | } | ||
705 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | ||
706 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data))) | ||
707 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update); | ||
708 | write_gnuplot_script (data_fn_update, GNUNET_NO); | ||
639 | } | 709 | } |
640 | 710 | ||
641 | next = ph.head; | 711 | next = ph.head; |
642 | while (NULL != (cur = next)) | 712 | while (NULL != (cur = next)) |
643 | { | 713 | { |
644 | next = cur->next; | 714 | next = cur->next; |
715 | str_d_total = NULL; | ||
716 | str_d_setup = NULL; | ||
717 | str_d_lp = NULL; | ||
718 | str_d_mlp = NULL; | ||
645 | 719 | ||
646 | /* Print log */ | 720 | /* Print log */ |
647 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) | 721 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) |
648 | { | 722 | { |
649 | fprintf (stderr, "Total time to solve for %u peers %u addresses: %llu us\n", | 723 | fprintf (stderr, "Total time to solve %s for %u peers %u addresses: %llu us\n", |
724 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
650 | cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us); | 725 | cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us); |
651 | GNUNET_asprintf(&str_d_total, "%llu", (unsigned long long )cur->d_total.rel_value_us); | 726 | GNUNET_asprintf(&str_d_total, "%llu", (unsigned long long )cur->d_total.rel_value_us); |
652 | } | 727 | } |
@@ -654,7 +729,8 @@ evaluate () | |||
654 | GNUNET_asprintf(&str_d_total, "-1"); | 729 | GNUNET_asprintf(&str_d_total, "-1"); |
655 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) | 730 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) |
656 | { | 731 | { |
657 | fprintf (stderr, "Total time to setup %u peers %u addresses: %llu us\n", | 732 | fprintf (stderr, "Total time to setup %s %u peers %u addresses: %llu us\n", |
733 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
658 | cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us); | 734 | cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us); |
659 | GNUNET_asprintf(&str_d_setup, "%llu", (unsigned long long )cur->d_setup.rel_value_us); | 735 | GNUNET_asprintf(&str_d_setup, "%llu", (unsigned long long )cur->d_setup.rel_value_us); |
660 | } | 736 | } |
@@ -662,7 +738,8 @@ evaluate () | |||
662 | GNUNET_asprintf(&str_d_setup, "-1"); | 738 | GNUNET_asprintf(&str_d_setup, "-1"); |
663 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) | 739 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) |
664 | { | 740 | { |
665 | fprintf (stderr, "Total time to solve LP for %u peers %u addresses: %llu us\n", | 741 | fprintf (stderr, "Total time to solve %s LP for %u peers %u addresses: %llu us\n", |
742 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
666 | cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us); | 743 | cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us); |
667 | GNUNET_asprintf(&str_d_lp, "%llu", (unsigned long long )cur->d_lp.rel_value_us); | 744 | GNUNET_asprintf(&str_d_lp, "%llu", (unsigned long long )cur->d_lp.rel_value_us); |
668 | } | 745 | } |
@@ -670,7 +747,8 @@ evaluate () | |||
670 | GNUNET_asprintf(&str_d_lp, "-1"); | 747 | GNUNET_asprintf(&str_d_lp, "-1"); |
671 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) | 748 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) |
672 | { | 749 | { |
673 | fprintf (stderr, "Total time to solve MLP for %u peers %u addresses: %llu us\n", | 750 | fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", |
751 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
674 | cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us); | 752 | cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us); |
675 | GNUNET_asprintf(&str_d_mlp, "%llu", (unsigned long long )cur->d_mlp.rel_value_us); | 753 | GNUNET_asprintf(&str_d_mlp, "%llu", (unsigned long long )cur->d_mlp.rel_value_us); |
676 | } | 754 | } |
@@ -686,24 +764,38 @@ evaluate () | |||
686 | str_d_setup, | 764 | str_d_setup, |
687 | str_d_lp, | 765 | str_d_lp, |
688 | str_d_mlp); | 766 | str_d_mlp); |
689 | 767 | if (cur->update == GNUNET_NO) | |
690 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 768 | { |
691 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn); | 769 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) |
692 | GNUNET_free (str_d_total); | 770 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full); |
693 | GNUNET_free (str_d_setup); | 771 | } |
694 | GNUNET_free (str_d_lp); | 772 | if (cur->update == GNUNET_YES) |
695 | GNUNET_free (str_d_mlp); | 773 | { |
774 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data))) | ||
775 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update); | ||
776 | } | ||
696 | GNUNET_free (data); | 777 | GNUNET_free (data); |
697 | } | 778 | } |
779 | GNUNET_free_non_null (str_d_total); | ||
780 | GNUNET_free_non_null (str_d_setup); | ||
781 | GNUNET_free_non_null (str_d_lp); | ||
782 | GNUNET_free_non_null (str_d_mlp); | ||
783 | |||
698 | GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur); | 784 | GNUNET_CONTAINER_DLL_remove (ph.head, ph.tail, cur); |
699 | GNUNET_free (cur); | 785 | GNUNET_free (cur); |
700 | } | 786 | } |
701 | 787 | ||
702 | if (GNUNET_YES == ph.create_plot) | 788 | if (GNUNET_YES == ph.create_plot) |
703 | { | 789 | { |
704 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 790 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_full)) |
705 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn); | 791 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn_full); |
706 | GNUNET_free (data_fn); | 792 | GNUNET_free (data_fn_full); |
793 | } | ||
794 | if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates)) | ||
795 | { | ||
796 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_update)) | ||
797 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", data_fn_update); | ||
798 | GNUNET_free (data_fn_update); | ||
707 | } | 799 | } |
708 | } | 800 | } |
709 | 801 | ||
@@ -726,12 +818,13 @@ perf_run () | |||
726 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 818 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
727 | "Added %u peers\n", cp); | 819 | "Added %u peers\n", cp); |
728 | 820 | ||
729 | /* Set initial bulk start to not solve */ | ||
730 | ph.env.sf.s_bulk_start (ph.solver); | ||
731 | ph.bulk_running = GNUNET_YES; | ||
732 | |||
733 | for (cp = 0; cp < count_p; cp++) | 821 | for (cp = 0; cp < count_p; cp++) |
734 | { | 822 | { |
823 | if (GNUNET_NO == ph.bulk_running) | ||
824 | { | ||
825 | ph.bulk_running = GNUNET_YES; | ||
826 | ph.env.sf.s_bulk_start (ph.solver); | ||
827 | } | ||
735 | ph.current_p = cp + 1; | 828 | ph.current_p = cp + 1; |
736 | for (ca = 0; ca < count_a; ca++) | 829 | for (ca = 0; ca < count_a; ca++) |
737 | { | 830 | { |
@@ -751,8 +844,8 @@ perf_run () | |||
751 | /* Disable bulk to solve the problem */ | 844 | /* Disable bulk to solve the problem */ |
752 | if (GNUNET_YES == ph.bulk_running) | 845 | if (GNUNET_YES == ph.bulk_running) |
753 | { | 846 | { |
754 | ph.bulk_running = GNUNET_NO; | ||
755 | ph.expecting_solution = GNUNET_YES; | 847 | ph.expecting_solution = GNUNET_YES; |
848 | ph.bulk_running = GNUNET_NO; | ||
756 | ph.env.sf.s_bulk_stop (ph.solver); | 849 | ph.env.sf.s_bulk_stop (ph.solver); |
757 | } | 850 | } |
758 | else | 851 | else |
@@ -761,27 +854,31 @@ perf_run () | |||
761 | } | 854 | } |
762 | 855 | ||
763 | /* Problem is solved by the solver here due to unlocking */ | 856 | /* Problem is solved by the solver here due to unlocking */ |
764 | |||
765 | ph.expecting_solution = GNUNET_NO; | 857 | ph.expecting_solution = GNUNET_NO; |
766 | /* Disable bulk to solve the problem */ | 858 | |
767 | if (GNUNET_NO == ph.bulk_running) | 859 | /* Update the problem */ |
768 | { | 860 | if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates)) |
769 | ph.env.sf.s_bulk_start (ph.solver); | ||
770 | ph.bulk_running = GNUNET_YES; | ||
771 | } | ||
772 | #if 0 | ||
773 | if ((0 < ph.opt_update_quantity) || (0 < ph.opt_update_percent)) | ||
774 | { | 861 | { |
775 | /* Update */ | 862 | /* Update */ |
776 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 863 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
777 | "Updating problem with %u peers and %u addresses\n", cp + 1, ca); | 864 | "Updating problem with %u peers and %u addresses\n", cp + 1, ca); |
778 | //ph.env.sf.s_bulk_start (ph.solver); | 865 | |
779 | //update_addresses (cp + 1, ca, ph.opt_update_quantity); | 866 | ph.expecting_solution = GNUNET_YES; |
780 | //ph.env.sf.s_bulk_stop (ph.solver); | 867 | if (GNUNET_NO == ph.bulk_running) |
868 | { | ||
869 | ph.bulk_running = GNUNET_YES; | ||
870 | ph.env.sf.s_bulk_start (ph.solver); | ||
871 | } | ||
872 | perf_update_all_addresses (cp + 1, ca, ph.opt_update_percent); | ||
873 | ph.bulk_running = GNUNET_NO; | ||
874 | ph.env.sf.s_bulk_stop (ph.solver); | ||
875 | /* Problem is solved by the solver here due to unlocking */ | ||
876 | ph.expecting_solution = GNUNET_NO; | ||
781 | } | 877 | } |
782 | #endif | 878 | GNUNET_assert (GNUNET_NO == ph.bulk_running); |
783 | } | 879 | } |
784 | } | 880 | } |
881 | |||
785 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 882 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
786 | "Done, cleaning up addresses\n"); | 883 | "Done, cleaning up addresses\n"); |
787 | if (GNUNET_NO == ph.bulk_running) | 884 | if (GNUNET_NO == ph.bulk_running) |
@@ -877,14 +974,6 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
877 | if (0 == ph.N_address) | 974 | if (0 == ph.N_address) |
878 | ph.N_address = DEFAULT_ADDRESSES; | 975 | ph.N_address = DEFAULT_ADDRESSES; |
879 | 976 | ||
880 | if (ph.opt_update_quantity > ph.N_address) | ||
881 | { | ||
882 | fprintf (stderr, | ||
883 | _("Trying to update more addresses than we have per peer! (%u vs %u)"), | ||
884 | ph.opt_update_quantity, ph.N_address); | ||
885 | exit (1); | ||
886 | } | ||
887 | |||
888 | if (ph.N_peers_start != ph.N_peers_end) | 977 | if (ph.N_peers_start != ph.N_peers_end) |
889 | fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses\n", | 978 | fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses\n", |
890 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 979 | ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); |
@@ -892,6 +981,9 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
892 | fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses\n", | 981 | fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses\n", |
893 | ph.ats_string, ph.N_peers_end, ph.N_address); | 982 | ph.ats_string, ph.N_peers_end, ph.N_address); |
894 | 983 | ||
984 | if (0 == ph.opt_update_percent) | ||
985 | ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE; | ||
986 | |||
895 | /* Load quotas */ | 987 | /* Load quotas */ |
896 | if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, | 988 | if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, |
897 | quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount)) | 989 | quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount)) |
@@ -950,13 +1042,13 @@ int | |||
950 | main (int argc, char *argv[]) | 1042 | main (int argc, char *argv[]) |
951 | { | 1043 | { |
952 | /* extract command line arguments */ | 1044 | /* extract command line arguments */ |
953 | ph.opt_update_quantity = 0; | ||
954 | ph.opt_update_percent = 0; | 1045 | ph.opt_update_percent = 0; |
955 | ph.N_peers_start = 0; | 1046 | ph.N_peers_start = 0; |
956 | ph.N_peers_end = 0; | 1047 | ph.N_peers_end = 0; |
957 | ph.N_address = 0; | 1048 | ph.N_address = 0; |
958 | ph.ats_string = NULL; | 1049 | ph.ats_string = NULL; |
959 | ph.create_plot = GNUNET_NO; | 1050 | ph.create_plot = GNUNET_NO; |
1051 | ph.measure_updates = GNUNET_NO; | ||
960 | 1052 | ||
961 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 1053 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
962 | { 'a', "addresses", NULL, | 1054 | { 'a', "addresses", NULL, |
@@ -971,12 +1063,12 @@ main (int argc, char *argv[]) | |||
971 | { 'p', "percentage", NULL, | 1063 | { 'p', "percentage", NULL, |
972 | gettext_noop ("update a fix percentage of addresses"), | 1064 | gettext_noop ("update a fix percentage of addresses"), |
973 | 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, | 1065 | 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent }, |
974 | { 'q', "quantity", NULL, | ||
975 | gettext_noop ("update a fix quantity of addresses"), | ||
976 | 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_quantity }, | ||
977 | { 'g', "gnuplot", NULL, | 1066 | { 'g', "gnuplot", NULL, |
978 | gettext_noop ("create GNUplot file"), | 1067 | gettext_noop ("create GNUplot file"), |
979 | 0, &GNUNET_GETOPT_set_one, &ph.create_plot}, | 1068 | 0, &GNUNET_GETOPT_set_one, &ph.create_plot}, |
1069 | { 'u', "update", NULL, | ||
1070 | gettext_noop ("measure updates"), | ||
1071 | 0, &GNUNET_GETOPT_set_one, &ph.measure_updates}, | ||
980 | GNUNET_GETOPT_OPTION_END | 1072 | GNUNET_GETOPT_OPTION_END |
981 | }; | 1073 | }; |
982 | 1074 | ||