2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats/perf_ats_solver.c
22 * @brief generic performance test for ATS solvers
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet_util_lib.h"
28 #include "gnunet_statistics_service.h"
29 #include "gnunet-service-ats_addresses.h"
30 #include "gnunet-service-ats_normalization.h"
31 #include "gnunet_ats_service.h"
32 #include "gnunet_ats_plugin.h"
33 #include "test_ats_api_common.h"
35 #define DEFAULT_UPDATE_PERCENTAGE 20
36 #define DEFAULT_PEERS_START 10
37 #define DEFAULT_PEERS_END 10
38 #define DEFAULT_ADDRESSES 10
39 #define DEFAULT_ATS_COUNT 2
41 #define GNUPLOT_PROP_TEMPLATE "#!/usr/bin/gnuplot \n" \
42 "set datafile separator ';' \n" \
43 "set title \"Execution time Proportional solver \" \n" \
44 "set xlabel \"Number of peers\" \n" \
45 "set ylabel \"Execution time in us\" \n" \
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" \
55 #define GNUPLOT_MLP_TEMPLATE "#!/usr/bin/gnuplot \n" \
56 "set datafile separator ';' \n" \
57 "set title \"Execution time MLP solver \" \n" \
58 "set xlabel \"Number of peers\" \n" \
59 "set ylabel \"Execution time in us\" \n" \
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" \
69 #define GNUPLOT_RIL_TEMPLATE "#!/usr/bin/gnuplot \n" \
70 "set datafile separator ';' \n" \
71 "set title \"Execution time RIL solver \" \n" \
72 "set xlabel \"Number of peers\" \n" \
73 "set ylabel \"Execution time in us\" \n" \
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" \
84 * Handle for ATS address component
91 struct PerfPeer *peers;
101 struct GNUNET_STATISTICS_Handle *stat;
104 * A multihashmap to store all addresses
106 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
111 struct GNUNET_ATS_PluginEnvironment env;
114 * Array for results for each iteration with length iterations
116 struct Iteration *iterations_results;
119 * Array to store averaged result with length #peers
121 struct Result *averaged_full_result;
123 struct Result *averaged_update_result;
128 struct Result *current_result;
134 * Solver description as string
139 * Configured ATS solver
144 * #peers to start benchmarking with
149 * #peers to end benchmarking with
154 * #addresses to benchmarking with
159 * Percentage of peers to update
161 int opt_update_percent;
164 * Create gnuplot file
174 * Number of iterations
181 int current_iteration;
184 * Is a bulk operation running?
189 * Is a bulk operation running?
191 int expecting_solution;
195 * Data structure to store results for a single iteration
200 * Head of the linked list
202 struct Result *result_head;
205 * Tail of the linked list
207 struct Result *result_tail;
212 * Result for a solver calculcation
217 * Previous element in the linked list
222 * Next element in the linked list
227 * Number of peers this solution included
232 * Number of addresses per peer this solution included
237 * Is this an update or a full solution
242 * Was the solution valid or did the solver fail
247 * Result of the solver
249 enum GAS_Solver_Additional_Information info;
252 * Duration of setting up the problem in the solver
254 struct GNUNET_TIME_Relative d_setup;
257 * Duration of solving the LP problem in the solver
260 struct GNUNET_TIME_Relative d_lp;
263 * Duration of solving the MLP problem in the solver
266 struct GNUNET_TIME_Relative d_mlp;
269 * Duration of solving whole problem in the solver
271 struct GNUNET_TIME_Relative d_total;
274 * Start time of setting up the problem in the solver
276 struct GNUNET_TIME_Absolute s_setup;
279 * Start time of solving the LP problem in the solver
282 struct GNUNET_TIME_Absolute s_lp;
285 * Start time of solving the MLP problem in the solver
288 struct GNUNET_TIME_Absolute s_mlp;
291 * Start time of solving whole problem in the solver
293 struct GNUNET_TIME_Absolute s_total;
296 * End time of setting up the problem in the solver
298 struct GNUNET_TIME_Absolute e_setup;
301 * End time of solving the LP problem in the solver
304 struct GNUNET_TIME_Absolute e_lp;
307 * End time of solving the MLP problem in the solver
310 struct GNUNET_TIME_Absolute e_mlp;
313 * End time of solving whole problem in the solver
315 struct GNUNET_TIME_Absolute e_total;
319 * Peer used for the benchmarking
326 struct GNUNET_PeerIdentity id;
329 * Head of linked list of addresses used with this peer
331 struct ATS_Address *head;
334 * Head of linked list of addresses used with this peer
336 struct ATS_Address *tail;
341 * ATS performance handle
343 static struct PerfHandle ph;
355 GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO);
359 if (NULL != addresses)
361 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL);
362 GNUNET_CONTAINER_multihashmap_destroy (addresses);
365 if (NULL != ph.peers)
367 GNUNET_free(ph.peers);
370 GAS_normalization_stop ();
376 perf_create_peer (int cp)
379 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
380 &ph.peers[cp].id, sizeof (struct GNUNET_PeerIdentity));
381 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating peer #%u: %s \n", cp,
382 GNUNET_i2s (&ph.peers[cp].id));
388 perf_update_address (struct ATS_Address *cur)
393 r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2);
397 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
398 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
399 "Updating peer `%s' address %p type %s val %u\n",
400 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val);
401 ph.env.sf.s_address_update_property (ph.solver, cur,
402 GNUNET_ATS_QUALITY_NET_DELAY,
403 r_val, (double) (100 + r_val / 100));
406 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10);
408 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
409 "Updating peer `%s' address %p type %s val %u\n",
410 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val);
411 ph.env.sf.s_address_update_property (ph.solver, cur,
412 GNUNET_ATS_QUALITY_NET_DISTANCE,
413 r_val, (double) (100 + r_val) / 100);
418 ph.env.sf.s_address_update_inuse (ph.solver, cur, GNUNET_YES);
423 bandwidth_changed_cb (void *cls,
424 struct ATS_Address *address)
426 if ( (0 == ntohl (address->assigned_bw_out.value__)) &&
427 (0 == ntohl (address->assigned_bw_in.value__)) )
430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
431 "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
432 GNUNET_i2s (&address->peer),
434 (unsigned int) ntohl (address->assigned_bw_out.value__),
435 (unsigned int) ntohl (address->assigned_bw_in.value__));
436 if (GNUNET_YES == ph.bulk_running)
443 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
445 return GAS_normalization_get_preferences_by_peer (id);
450 get_property_cb (void *cls, const struct ATS_Address *address)
452 return GAS_normalization_get_properties ((struct ATS_Address *) address);
456 normalized_property_changed_cb (void *cls, struct ATS_Address *peer,
457 uint32_t type, double prop_rel)
463 perf_address_initial_update (void *solver,
464 struct GNUNET_CONTAINER_MultiPeerMap * addresses,
465 struct ATS_Address *address)
467 ph.env.sf.s_address_update_property (solver, address, GNUNET_ATS_QUALITY_NET_DELAY,
469 (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100))
472 ph.env.sf.s_address_update_property (solver, address,
473 GNUNET_ATS_QUALITY_NET_DISTANCE, 10,
474 (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100))
479 perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers)
481 struct ATS_Address *cur_address;
490 count = cp * ((double) percentage_peers / 100);
491 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
492 "Updating %u of %u peers \n", count, cp);
494 for (c_peer = 0; c_peer < cp; c_peer++)
499 while (c_select < count)
501 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, cp);
505 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
506 "Updating peer [%u] \n", r);
510 for (c_cur_p = 0; c_cur_p < cp; c_cur_p++)
514 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca);
515 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
516 "Updating peer [%u] address [%u]\n", c_cur_p, r);
519 for (cur_address = ph.peers[c_cur_p].head; NULL != cur_address; cur_address = cur_address->next)
522 perf_update_address (cur_address);
531 static struct ATS_Address *
532 perf_create_address (int cp, int ca)
534 struct ATS_Address *a;
535 a = create_address (&ph.peers[cp].id,
536 "Test 1", "test 1", strlen ("test 1") + 1, 0);
537 GNUNET_CONTAINER_DLL_insert (ph.peers[cp].head, ph.peers[cp].tail, a);
538 GNUNET_CONTAINER_multipeermap_put (ph.addresses, &ph.peers[cp].id, a,
539 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
544 solver_info_cb (void *cls,
545 enum GAS_Solver_Operation op,
546 enum GAS_Solver_Status stat,
547 enum GAS_Solver_Additional_Information add)
552 add_info = "GAS_INFO_NONE";
555 add_info = "GAS_INFO_MLP_FULL";
557 case GAS_INFO_UPDATED:
558 add_info = "GAS_INFO_MLP_UPDATED";
560 case GAS_INFO_PROP_ALL:
561 add_info = "GAS_INFO_PROP_ALL";
563 case GAS_INFO_PROP_SINGLE:
564 add_info = "GAS_INFO_PROP_SINGLE";
567 add_info = "INVALID";
574 case GAS_OP_SOLVE_START:
575 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
576 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
577 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
578 if (GNUNET_NO == ph.expecting_solution)
580 /* We do not expect a solution at the moment */
585 if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result))
587 /* Create new result */
588 tmp = GNUNET_new (struct Result);
589 ph.current_result = tmp;
590 GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head,
591 ph.iterations_results[ph.current_iteration-1].result_tail, tmp);
592 ph.current_result->addresses = ph.current_a;
593 ph.current_result->peers = ph.current_p;
594 ph.current_result->s_total = GNUNET_TIME_absolute_get();
595 ph.current_result->d_total = GNUNET_TIME_UNIT_FOREVER_REL;
596 ph.current_result->d_setup = GNUNET_TIME_UNIT_FOREVER_REL;
597 ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
598 ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
599 ph.current_result->info = add;
600 if (add == GAS_INFO_UPDATED)
601 ph.current_result->update = GNUNET_YES;
603 ph.current_result->update = GNUNET_NO;
606 case GAS_OP_SOLVE_STOP:
607 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
608 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
609 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
610 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
612 /* We do not expect a solution at the moment */
617 if (GAS_STAT_SUCCESS == stat)
618 ph.current_result->valid = GNUNET_YES;
620 ph.current_result->valid = GNUNET_NO;
622 if (NULL != ph.current_result)
624 /* Finalize result */
625 ph.current_result->e_total = GNUNET_TIME_absolute_get ();
626 ph.current_result->d_total = GNUNET_TIME_absolute_get_difference (
627 ph.current_result->s_total, ph.current_result->e_total);
629 ph.current_result = NULL;
632 case GAS_OP_SOLVE_SETUP_START:
633 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
634 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
635 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
636 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
642 if (GAS_STAT_SUCCESS == stat)
643 ph.current_result->valid = GNUNET_YES;
645 ph.current_result->valid = GNUNET_NO;
647 ph.current_result->s_setup = GNUNET_TIME_absolute_get ();
650 case GAS_OP_SOLVE_SETUP_STOP:
651 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
652 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
653 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
654 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
660 if (GAS_STAT_SUCCESS == stat)
661 ph.current_result->valid = GNUNET_YES;
663 ph.current_result->valid = GNUNET_NO;
665 ph.current_result->e_setup = GNUNET_TIME_absolute_get ();
666 ph.current_result->d_setup = GNUNET_TIME_absolute_get_difference (
667 ph.current_result->s_setup, ph.current_result->e_setup);
670 case GAS_OP_SOLVE_MLP_LP_START:
671 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
672 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
673 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
674 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
680 if (GAS_STAT_SUCCESS == stat)
681 ph.current_result->valid = GNUNET_YES;
683 ph.current_result->valid = GNUNET_NO;
685 ph.current_result->s_lp = GNUNET_TIME_absolute_get ();
687 case GAS_OP_SOLVE_MLP_LP_STOP:
688 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
689 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
690 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
691 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
697 if (GAS_STAT_SUCCESS == stat)
698 ph.current_result->valid = GNUNET_YES;
700 ph.current_result->valid = GNUNET_NO;
702 ph.current_result->e_lp = GNUNET_TIME_absolute_get ();
703 ph.current_result->d_lp = GNUNET_TIME_absolute_get_difference (
704 ph.current_result->s_lp, ph.current_result->e_lp);
707 case GAS_OP_SOLVE_MLP_MLP_START:
708 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
709 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
710 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
711 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
717 if (GAS_STAT_SUCCESS == stat)
718 ph.current_result->valid = GNUNET_YES;
720 ph.current_result->valid = GNUNET_NO;
722 ph.current_result->s_mlp = GNUNET_TIME_absolute_get ();
724 case GAS_OP_SOLVE_MLP_MLP_STOP:
725 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
726 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
727 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
728 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
734 if (GAS_STAT_SUCCESS == stat)
735 ph.current_result->valid = GNUNET_YES;
737 ph.current_result->valid = GNUNET_NO;
739 ph.current_result->e_mlp = GNUNET_TIME_absolute_get ();
740 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference (
741 ph.current_result->s_mlp, ph.current_result->e_mlp);
743 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
744 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
745 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
746 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
748 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
749 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
750 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
751 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
752 if (GAS_STAT_SUCCESS != stat)
754 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
755 "Solver `%s' failed to update problem with %u peers and %u address!\n",
756 ph.ats_string, ph.current_p, ph.current_a);
766 write_gnuplot_script (char * data_fn, int iteration, int full)
768 struct GNUNET_DISK_FileHandle *f;
775 switch (ph.ats_mode) {
776 case MODE_PROPORTIONAL:
777 if (GNUNET_YES == full)
778 template = GNUPLOT_PROP_TEMPLATE;
780 template = GNUPLOT_PROP_UPDATE_TEMPLATE;
783 if (GNUNET_YES == full)
784 template = GNUPLOT_MLP_TEMPLATE;
786 template = GNUPLOT_MLP_UPDATE_TEMPLATE;
789 if (GNUNET_YES == full)
790 template = GNUPLOT_RIL_TEMPLATE;
792 template = GNUPLOT_RIL_UPDATE_TEMPLATE;
799 GNUNET_asprintf (&iter_text, "%s_%u", "avg",ph.iterations);
801 GNUNET_asprintf (&iter_text, "%u", iteration);
802 if (GNUNET_YES == full)
804 GNUNET_asprintf (&gfn, "perf_%s_full_%s-%u_%u_%u.gnuplot",
813 GNUNET_asprintf (&gfn, "perf_%s_updat_%s-%u_%u_%u.gnuplot",
820 GNUNET_free (iter_text);
822 f = GNUNET_DISK_file_open (gfn,
823 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
824 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
827 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
832 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, template, strlen(template)))
833 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
836 if (MODE_PROPORTIONAL == ph.ats_mode)
838 GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
842 else if (MODE_MLP == ph.ats_mode)
844 GNUNET_asprintf (&data, "plot '%s' using 1:%u with lines title 'Total time to solve',\\\n" \
845 "'%s' using 1:%u with lines title 'Time to setup',\\\n"
846 "'%s' using 1:%u with lines title 'Time to solve LP',\\\n"
847 "'%s' using 1:%u with lines title 'Total time to solve MLP'\n" \
854 else if (MODE_RIL == ph.ats_mode)
856 GNUNET_asprintf (&data,
857 "plot '%s' using 1:%u with lines title 'Total time to solve'\n" \
862 if ((NULL != data) &&
863 (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen(data))))
864 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
865 "Cannot write data to plot file `%s'\n",
867 GNUNET_free_non_null (data);
869 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
870 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
871 "Cannot close gnuplot file `%s'\n",
874 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
875 "Data successfully written to plot file `%s'\n",
882 * Evaluate results for a specific iteration
884 * @param iteration the iteration to evaluate
888 evaluate (int iteration)
890 struct GNUNET_DISK_FileHandle *f_full;
891 struct GNUNET_DISK_FileHandle *f_update;
893 char * data_fn_update;
897 struct Result *cur_res;
912 GNUNET_asprintf (&iter_text, "%s", "avg");
914 GNUNET_asprintf (&iter_text, "%u", iteration);
915 GNUNET_asprintf (&data_fn_full,
916 "perf_%s_full_%s_%u_%u_%u.data",
922 GNUNET_free (iter_text);
923 f_full = GNUNET_DISK_file_open (data_fn_full,
924 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
925 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
928 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
929 "Cannot open gnuplot file `%s'\n",
931 GNUNET_free (data_fn_full);
934 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
935 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
936 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
937 "Cannot write data to log file `%s'\n",
939 write_gnuplot_script (data_fn_full, iteration, GNUNET_YES);
942 data_fn_update = NULL;
943 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates))
946 GNUNET_asprintf (&iter_text, "%s", "avg");
948 GNUNET_asprintf (&iter_text, "%u", iteration);
949 GNUNET_asprintf (&data_fn_update, "perf_%s_update_i%u_%u_%u_%u.data",
955 GNUNET_free (iter_text);
956 f_update = GNUNET_DISK_file_open (data_fn_update,
957 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
958 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
959 if (NULL == f_update)
961 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
962 "Cannot open gnuplot file `%s'\n", data_fn_update);
963 GNUNET_free (data_fn_update);
965 GNUNET_DISK_file_close (f_full);
966 GNUNET_free (data_fn_full);
969 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
970 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
971 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
972 "Cannot write data to log file `%s'\n",
974 write_gnuplot_script (data_fn_update, iteration, GNUNET_NO);
977 next = ph.iterations_results[ph.current_iteration -1].result_head;
978 while (NULL != (cur = next))
987 if (GNUNET_NO == cur->update)
988 cur_res = &ph.averaged_full_result[cur->peers - ph.N_peers_start];
990 cur_res = &ph.averaged_update_result[cur->peers - ph.N_peers_start];
992 cur_res->peers = cur->peers;
993 cur_res->addresses = cur->addresses;
994 cur_res->update = cur->update;
996 if (GNUNET_NO == cur->valid)
999 "Total time to solve %s for %u peers %u addresses: %s\n",
1000 (GNUNET_YES == cur->update) ? "updated" : "full",
1001 cur->peers, cur->addresses, "Failed to solve!");
1007 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
1009 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_total.rel_value_us)
1010 cur_res->d_total.rel_value_us = 0;
1011 if (GNUNET_YES == cur->valid)
1012 cur_res->d_total.rel_value_us += cur->d_total.rel_value_us;
1014 "Total time to solve %s for %u peers %u addresses: %llu us\n",
1015 (GNUNET_YES == cur->update) ? "updated" : "full",
1016 cur->peers, cur->addresses, (unsigned long long) cur->d_total.rel_value_us);
1017 GNUNET_asprintf(&str_d_total,
1019 (unsigned long long) cur->d_total.rel_value_us);
1022 GNUNET_asprintf(&str_d_total, "-1");
1023 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us)
1025 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_setup.rel_value_us)
1026 cur_res->d_setup.rel_value_us = 0;
1027 if (GNUNET_YES == cur->valid)
1028 cur_res->d_setup.rel_value_us += cur->d_setup.rel_value_us;
1029 fprintf (stderr, "Total time to setup %s %u peers %u addresses: %llu us\n",
1030 (GNUNET_YES == cur->update) ? "updated" : "full",
1031 cur->peers, cur->addresses, (unsigned long long )cur->d_setup.rel_value_us);
1032 GNUNET_asprintf(&str_d_setup, "%llu", (unsigned long long )cur->d_setup.rel_value_us);
1035 GNUNET_asprintf(&str_d_setup, "-1");
1036 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us)
1038 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_lp.rel_value_us)
1039 cur_res->d_lp.rel_value_us = 0;
1040 if (GNUNET_YES == cur->valid)
1041 cur_res->d_lp.rel_value_us += cur->d_lp.rel_value_us;
1043 "Total time to solve %s LP for %u peers %u addresses: %llu us\n",
1044 (GNUNET_YES == cur->update) ? "updated" : "full",
1047 (unsigned long long )cur->d_lp.rel_value_us);
1048 GNUNET_asprintf (&str_d_lp,
1050 (unsigned long long )cur->d_lp.rel_value_us);
1053 GNUNET_asprintf (&str_d_lp, "-1");
1054 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us)
1056 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_mlp.rel_value_us)
1057 cur_res->d_mlp.rel_value_us = 0;
1058 if (GNUNET_YES == cur->valid)
1059 cur_res->d_mlp.rel_value_us += cur->d_mlp.rel_value_us;
1061 fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n",
1062 (GNUNET_YES == cur->update) ? "updated" : "full",
1063 cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us);
1064 GNUNET_asprintf (&str_d_mlp,
1066 (unsigned long long )cur->d_mlp.rel_value_us);
1069 GNUNET_asprintf (&str_d_mlp, "-1");
1072 if (GNUNET_YES == ph.create_plot)
1075 GNUNET_asprintf (&data,
1076 "%u;%u;%s;%s;%s;%s\n",
1077 cur->peers, cur->addresses,
1082 if (cur->update == GNUNET_NO)
1084 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data)))
1085 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1086 "Cannot write data to log file `%s'\n",
1089 if ((cur->update == GNUNET_YES) && (NULL != f_update))
1091 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1092 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1093 "Cannot write data to log file `%s'\n",
1098 GNUNET_free_non_null (str_d_total);
1099 GNUNET_free_non_null (str_d_setup);
1100 GNUNET_free_non_null (str_d_lp);
1101 GNUNET_free_non_null (str_d_mlp);
1103 GNUNET_CONTAINER_DLL_remove (ph.iterations_results[ph.current_iteration-1].result_head,
1104 ph.iterations_results[ph.current_iteration-1].result_tail, cur);
1108 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1109 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1111 GNUNET_free_non_null (data_fn_full);
1113 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1114 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1116 GNUNET_free_non_null (data_fn_update);
1121 evaluate_average (void)
1125 struct GNUNET_DISK_FileHandle *f_full;
1126 struct GNUNET_DISK_FileHandle *f_update;
1127 char * data_fn_full;
1128 char * data_fn_update;
1138 data_fn_full = NULL;
1142 GNUNET_asprintf (&data_fn_full,
1143 "perf_%s_full_avg_%u-%u_%u_%u.data",
1149 f_full = GNUNET_DISK_file_open (data_fn_full,
1150 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
1151 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
1154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1155 "Cannot open gnuplot file `%s'\n",
1157 GNUNET_free (data_fn_full);
1160 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1161 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
1162 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1163 "Cannot write data to log file `%s'\n",
1165 write_gnuplot_script (data_fn_full, -1, GNUNET_YES);
1168 data_fn_update = NULL;
1169 if ((ph.create_plot) && (GNUNET_YES == ph.measure_updates))
1171 GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data",
1177 f_update = GNUNET_DISK_file_open (data_fn_update,
1178 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
1179 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
1180 if (NULL == f_update)
1182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1183 "Cannot open gnuplot file `%s'\n", data_fn_update);
1184 GNUNET_free (data_fn_update);
1186 GNUNET_DISK_file_close (f_full);
1187 GNUNET_free (data_fn_full);
1190 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1191 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1193 "Cannot write data to log file `%s'\n",
1195 write_gnuplot_script (data_fn_update, -1, GNUNET_NO);
1198 for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++)
1200 struct Result *cur = &ph.averaged_full_result[c];
1207 if (0 >= cur->valid)
1210 "No valid results for %s for %u peers %u addresses!\n",
1211 (GNUNET_YES == cur->update) ? "updated" : "full",
1212 cur->peers, cur->addresses);
1218 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
1221 "Average total time from %u iterations to solve %s for %u peers %u addresses: %llu us\n",
1223 (GNUNET_YES == cur->update) ? "updated" : "full",
1224 cur->peers, cur->addresses,
1225 (unsigned long long) cur->d_total.rel_value_us / cur->valid);
1226 GNUNET_asprintf(&str_d_total, "%llu",
1227 (unsigned long long) cur->d_total.rel_value_us / cur->valid);
1230 GNUNET_asprintf (&str_d_total, "-1");
1232 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us)
1235 "Average total time from %u iterations to setup for %u peers %u addresses: %llu us\n",
1236 cur->valid, cur->peers, cur->addresses,
1237 (unsigned long long) cur->d_setup.rel_value_us / cur->valid);
1238 GNUNET_asprintf(&str_d_setup, "%llu",
1239 (unsigned long long) cur->d_setup.rel_value_us / cur->valid);
1243 GNUNET_asprintf (&str_d_setup, "-1");
1245 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us)
1248 "Average total time from %u iterations to solve lp %s for %u peers %u addresses: %llu us\n",
1250 (GNUNET_YES == cur->update) ? "updated" : "full",
1251 cur->peers, cur->addresses,
1252 (unsigned long long) cur->d_lp.rel_value_us / cur->valid);
1253 GNUNET_asprintf(&str_d_lp, "%llu",
1254 (unsigned long long) cur->d_lp.rel_value_us / ph.iterations);
1257 GNUNET_asprintf (&str_d_lp, "-1");
1259 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us)
1262 "Average total time from %u iterations to solve mlp %s for %u peers %u addresses: %llu us\n",
1264 (GNUNET_YES == cur->update) ? "updated" : "full",
1265 cur->peers, cur->addresses,
1266 (unsigned long long) cur->d_mlp.rel_value_us / cur->valid);
1267 GNUNET_asprintf(&str_d_mlp, "%llu",
1268 (unsigned long long) cur->d_mlp.rel_value_us / cur->valid);
1271 GNUNET_asprintf (&str_d_mlp, "-1");
1274 if (GNUNET_YES == ph.create_plot)
1276 GNUNET_asprintf (&data,
1277 "%u;%u;%s;%s;%s;%s\n",
1278 cur->peers, cur->addresses,
1283 if (cur->update == GNUNET_NO)
1285 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data)))
1286 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1287 "Cannot write data to log file `%s'\n",
1290 if ((cur->update == GNUNET_YES) && (NULL != f_update))
1292 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1293 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1294 "Cannot write data to log file `%s'\n",
1300 GNUNET_free_non_null (str_d_total);
1301 GNUNET_free_non_null (str_d_setup);
1302 GNUNET_free_non_null (str_d_lp);
1303 GNUNET_free_non_null (str_d_mlp);
1306 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1307 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1309 GNUNET_free_non_null (data_fn_full);
1311 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1312 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1314 GNUNET_free_non_null (data_fn_update);
1320 struct ATS_Address *cur;
1321 struct ATS_Address *next;
1324 int count_p = ph.N_peers_end;
1325 int count_a = ph.N_address;
1326 struct ATS_Address * cur_addr;
1329 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
1330 for (cp = 0; cp < count_p; cp++)
1331 perf_create_peer (cp);
1332 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1333 "Iteration %u of %u, added %u peers\n", ph.current_iteration, ph.iterations, cp);
1335 for (cp = 0; cp < count_p; cp++)
1337 if (GNUNET_NO == ph.bulk_running)
1339 ph.bulk_running = GNUNET_YES;
1340 ph.env.sf.s_bulk_start (ph.solver);
1342 ph.current_p = cp + 1;
1343 for (ca = 0; ca < count_a; ca++)
1345 cur_addr = perf_create_address (cp, ca);
1347 ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount));
1348 ph.current_a = ca + 1;
1349 perf_address_initial_update (ph.solver, ph.addresses, cur_addr);
1350 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1351 "Adding address for peer %u address %u\n", cp, ca);
1353 /* Notify solver about request */
1354 ph.env.sf.s_get (ph.solver, &ph.peers[cp].id);
1356 if (cp + 1 >= ph.N_peers_start)
1358 /* Disable bulk to solve the problem */
1359 if (GNUNET_YES == ph.bulk_running)
1361 ph.expecting_solution = GNUNET_YES;
1362 ph.bulk_running = GNUNET_NO;
1363 ph.env.sf.s_bulk_stop (ph.solver);
1370 /* Problem is solved by the solver here due to unlocking */
1371 ph.expecting_solution = GNUNET_NO;
1373 /* Update the problem */
1374 if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates))
1377 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1378 "Updating problem with %u peers and %u addresses\n", cp + 1, ca);
1380 ph.expecting_solution = GNUNET_YES;
1381 if (GNUNET_NO == ph.bulk_running)
1383 ph.bulk_running = GNUNET_YES;
1384 ph.env.sf.s_bulk_start (ph.solver);
1386 perf_update_all_addresses (cp + 1, ca, ph.opt_update_percent);
1387 ph.bulk_running = GNUNET_NO;
1388 ph.env.sf.s_bulk_stop (ph.solver);
1389 /* Problem is solved by the solver here due to unlocking */
1390 ph.expecting_solution = GNUNET_NO;
1392 GNUNET_assert (GNUNET_NO == ph.bulk_running);
1396 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1397 "Done, cleaning up addresses\n");
1398 if (GNUNET_NO == ph.bulk_running)
1400 ph.env.sf.s_bulk_start (ph.solver);
1401 ph.bulk_running = GNUNET_YES;
1404 for (cp = 0; cp < count_p; cp++)
1406 for (cur = ph.peers[cp].head; cur != NULL ; cur = next)
1408 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1409 "Deleting addresses for peer %u\n", cp);
1410 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (ph.addresses,
1411 &ph.peers[cp].id, cur));
1412 ph.env.sf.s_del (ph.solver, cur, GNUNET_NO);
1414 GNUNET_CONTAINER_DLL_remove(ph.peers[cp].head, ph.peers[cp].tail, cur);
1419 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1420 "Iteration done\n");
1421 GNUNET_free(ph.peers);
1426 run (void *cls, char * const *args, const char *cfgfile,
1427 const struct GNUNET_CONFIGURATION_Handle *cfg)
1429 GNUNET_log_setup ("perf-ats-solver", "WARNING", NULL);
1431 char *src_filename = GNUNET_strdup (__FILE__);
1432 char *test_filename = cls;
1435 struct GNUNET_CONFIGURATION_Handle *solver_cfg;
1436 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
1437 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
1440 /* Extract test name */
1441 if (NULL == (sep = (strstr (src_filename,".c"))))
1443 GNUNET_free (src_filename);
1450 if (NULL != (sep = strstr (test_filename, ".exe")))
1453 if (NULL == (solver = strstr (test_filename, src_filename)))
1455 GNUNET_free (src_filename);
1460 solver += strlen (src_filename) +1;
1462 if (0 == strcmp(solver, "proportional"))
1464 ph.ats_mode = MODE_PROPORTIONAL;
1465 ph.ats_string = "proportional";
1467 else if (0 == strcmp(solver, "mlp"))
1469 ph.ats_mode = MODE_MLP;
1470 ph.ats_string = "mlp";
1472 else if ((0 == strcmp(solver, "ril")))
1474 ph.ats_mode = MODE_RIL;
1475 ph.ats_string = "ril";
1479 GNUNET_free (src_filename);
1484 GNUNET_free (src_filename);
1486 /* Calculcate peers */
1487 if ((0 == ph.N_peers_start) && (0 == ph.N_peers_end))
1489 ph.N_peers_start = DEFAULT_PEERS_START;
1490 ph.N_peers_end = DEFAULT_PEERS_END;
1492 if (0 == ph.N_address)
1493 ph.N_address = DEFAULT_ADDRESSES;
1495 if (ph.N_peers_start != ph.N_peers_end)
1496 fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses in %u iterations\n",
1497 ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, ph.iterations);
1499 fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses in %u iterations\n",
1500 ph.ats_string, ph.N_peers_end, ph.N_address, ph.iterations);
1502 if (0 == ph.opt_update_percent)
1503 ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE;
1506 solver_cfg = GNUNET_CONFIGURATION_create();
1507 if ((NULL == solver_cfg) || (GNUNET_SYSERR == (GNUNET_CONFIGURATION_load ( solver_cfg, "perf_ats_solver.conf"))))
1513 if (GNUNET_ATS_NetworkTypeCount != load_quotas (solver_cfg,
1514 quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
1521 /* Create array of DLL to store results for iterations */
1522 ph.iterations_results = GNUNET_malloc (sizeof (struct Iteration) * ph.iterations);
1523 ph.averaged_full_result = GNUNET_malloc (sizeof (struct Result) * ((ph.N_peers_end + 1) - ph.N_peers_start));
1524 ph.averaged_update_result = GNUNET_malloc (sizeof (struct Result) * ((ph.N_peers_end + 1) - ph.N_peers_start));
1525 for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++)
1527 ph.averaged_full_result[c].d_setup = GNUNET_TIME_UNIT_FOREVER_REL;
1528 ph.averaged_full_result[c].d_total = GNUNET_TIME_UNIT_FOREVER_REL;
1529 ph.averaged_full_result[c].d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
1530 ph.averaged_full_result[c].d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
1534 ph.env.cfg = solver_cfg;
1535 ph.stat = GNUNET_STATISTICS_create ("ats", cfg);
1536 ph.env.stats = ph.stat;
1537 ph.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
1538 ph.env.addresses = ph.addresses;
1539 ph.env.bandwidth_changed_cb = bandwidth_changed_cb;
1540 ph.env.get_preferences = &get_preferences_cb;
1541 ph.env.get_property = &get_property_cb;
1542 ph.env.network_count = GNUNET_ATS_NetworkTypeCount;
1543 ph.env.info_cb = &solver_info_cb;
1544 ph.env.info_cb_cls = NULL;
1546 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
1547 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1549 ph.env.networks[c] = networks[c];
1550 ph.env.out_quota[c] = quotas_out[c];
1551 ph.env.in_quota[c] = quotas_in[c];
1552 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loading network quotas: `%s' %llu %llu \n",
1553 GNUNET_ATS_print_network_type(ph.env.networks[c]),
1554 ph.env.out_quota[c],
1555 ph.env.in_quota[c]);
1557 GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL );
1559 GNUNET_asprintf (&plugin, "libgnunet_plugin_ats_%s", ph.ats_string);
1560 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s'\n"), ph.ats_string);
1561 if (NULL == (ph.solver = GNUNET_PLUGIN_load (plugin, &ph.env)))
1563 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize solver `%s'!\n"), plugin);
1568 /* Do the benchmark */
1569 for (ph.current_iteration = 1; ph.current_iteration <= ph.iterations; ph.current_iteration++)
1572 evaluate (ph.current_iteration);
1574 evaluate_average ();
1577 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string);
1578 GNUNET_PLUGIN_unload (plugin, ph.solver);
1579 GNUNET_free (plugin);
1580 GNUNET_free (ph.iterations_results);
1581 GNUNET_free (ph.averaged_full_result);
1582 GNUNET_free (ph.averaged_update_result);
1583 GNUNET_CONFIGURATION_destroy (solver_cfg);
1584 GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO);
1589 main (int argc, char *argv[])
1591 /* extract command line arguments */
1592 ph.opt_update_percent = 0;
1593 ph.N_peers_start = 0;
1596 ph.ats_string = NULL;
1597 ph.create_plot = GNUNET_NO;
1598 ph.measure_updates = GNUNET_NO;
1601 static struct GNUNET_GETOPT_CommandLineOption options[] = {
1602 { 'a', "addresses", NULL,
1603 gettext_noop ("addresses to use"),
1604 1, &GNUNET_GETOPT_set_uint, &ph.N_address },
1605 { 's', "start", NULL,
1606 gettext_noop ("start with peer"),
1607 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_start },
1609 gettext_noop ("end with peer"),
1610 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end },
1611 { 'i', "iterations", NULL,
1612 gettext_noop ("number of iterations used for averaging (default: 1)"),
1613 1, &GNUNET_GETOPT_set_uint, &ph.iterations },
1614 { 'p', "percentage", NULL,
1615 gettext_noop ("update a fix percentage of addresses"),
1616 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },
1617 { 'g', "gnuplot", NULL,
1618 gettext_noop ("create GNUplot file"),
1619 0, &GNUNET_GETOPT_set_one, &ph.create_plot},
1620 { 'u', "update", NULL,
1621 gettext_noop ("measure updates"),
1622 0, &GNUNET_GETOPT_set_one, &ph.measure_updates},
1623 GNUNET_GETOPT_OPTION_END
1626 GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]);
1631 /* end of file perf_ats_solver.c */