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
43 * Handle for ATS address component
50 struct PerfPeer *peers;
60 struct GNUNET_STATISTICS_Handle *stat;
63 * A multihashmap to store all addresses
65 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
70 struct GNUNET_ATS_PluginEnvironment env;
73 * Array for results for each iteration with length iterations
75 struct Iteration *iterations_results;
78 * Array to store averaged full solution result with length #peers
80 struct Result *averaged_full_result;
83 * Array to store averaged updated solution result with length #peers
85 struct Result *averaged_update_result;
90 struct Result *current_result;
93 * Current number of peers benchmarked
98 * Current number of addresses benchmarked
103 * Solver description as string
108 * Configured ATS solver
113 * #peers to start benchmarking with
118 * #peers to end benchmarking with
123 * #addresses to benchmarking with
128 * Percentage of peers to update
130 int opt_update_percent;
133 * Create gnuplot file
143 * Number of iterations
145 int total_iterations;
150 int current_iteration;
153 * Is a bulk operation running?
158 * Is a bulk operation running?
160 int expecting_solution;
163 * Was the problem just updates?
165 int performed_update;
169 * Data structure to store results for a single iteration
173 struct Result **results_array;
175 * Head of the linked list
177 struct Result *result_head;
180 * Tail of the linked list
182 struct Result *result_tail;
187 * Result for a solver calculcation
192 * Previous element in the linked list
197 * Next element in the linked list
202 * Number of peers this solution included
207 * Number of addresses per peer this solution included
212 * Is this an update or a full solution
217 * Was the solution valid or did the solver fail
222 * Result of the solver
224 enum GAS_Solver_Additional_Information info;
227 * Duration of setting up the problem in the solver
229 struct GNUNET_TIME_Relative d_setup;
232 * Duration of solving the LP problem in the solver
235 struct GNUNET_TIME_Relative d_lp;
238 * Duration of solving the MLP problem in the solver
241 struct GNUNET_TIME_Relative d_mlp;
244 * Duration of solving whole problem in the solver
246 struct GNUNET_TIME_Relative d_total;
249 * Start time of setting up the problem in the solver
251 struct GNUNET_TIME_Absolute s_setup;
254 * Start time of solving the LP problem in the solver
257 struct GNUNET_TIME_Absolute s_lp;
260 * Start time of solving the MLP problem in the solver
263 struct GNUNET_TIME_Absolute s_mlp;
266 * Start time of solving whole problem in the solver
268 struct GNUNET_TIME_Absolute s_total;
271 * End time of setting up the problem in the solver
273 struct GNUNET_TIME_Absolute e_setup;
276 * End time of solving the LP problem in the solver
279 struct GNUNET_TIME_Absolute e_lp;
282 * End time of solving the MLP problem in the solver
285 struct GNUNET_TIME_Absolute e_mlp;
288 * End time of solving whole problem in the solver
290 struct GNUNET_TIME_Absolute e_total;
294 * Peer used for the benchmarking
301 struct GNUNET_PeerIdentity id;
304 * Head of linked list of addresses used with this peer
306 struct ATS_Address *head;
309 * Head of linked list of addresses used with this peer
311 struct ATS_Address *tail;
316 * ATS performance handle
318 static struct PerfHandle ph;
334 GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO);
338 GNUNET_free_non_null (ph.peers);
339 GNUNET_free_non_null (ph.iterations_results);
340 GNUNET_free_non_null (ph.averaged_full_result);
341 GNUNET_free_non_null (ph.averaged_update_result);
343 GAS_normalization_stop ();
349 * Create a peer used for benchmarking
351 * @param cp the number of the peer
354 perf_create_peer (int cp)
357 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
358 &ph.peers[cp].id, sizeof (struct GNUNET_PeerIdentity));
359 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating peer #%u: %s \n", cp,
360 GNUNET_i2s (&ph.peers[cp].id));
365 * Perform an update for an address
367 * @param cur the address to update
370 perf_update_address (struct ATS_Address *cur)
375 r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2);
379 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
380 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
381 "Updating peer `%s' address %p type %s val %u\n",
382 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val);
383 ph.env.sf.s_address_update_property (ph.solver, cur,
384 GNUNET_ATS_QUALITY_NET_DELAY,
385 r_val, (double) (100 + r_val / 100));
388 r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10);
390 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
391 "Updating peer `%s' address %p type %s val %u\n",
392 GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val);
393 ph.env.sf.s_address_update_property (ph.solver, cur,
394 GNUNET_ATS_QUALITY_NET_DISTANCE,
395 r_val, (double) (100 + r_val) / 100);
400 ph.env.sf.s_address_update_inuse (ph.solver, cur, GNUNET_YES);
405 bandwidth_changed_cb (void *cls,
406 struct ATS_Address *address)
408 if ( (0 == ntohl (address->assigned_bw_out.value__)) &&
409 (0 == ntohl (address->assigned_bw_in.value__)) )
412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
413 "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
414 GNUNET_i2s (&address->peer),
416 (unsigned int) ntohl (address->assigned_bw_out.value__),
417 (unsigned int) ntohl (address->assigned_bw_in.value__));
418 if (GNUNET_YES == ph.bulk_running)
425 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
427 return GAS_normalization_get_preferences_by_peer (id);
432 get_property_cb (void *cls, const struct ATS_Address *address)
434 return GAS_normalization_get_properties ((struct ATS_Address *) address);
438 normalized_property_changed_cb (void *cls, struct ATS_Address *peer,
439 uint32_t type, double prop_rel)
445 perf_address_initial_update (void *solver,
446 struct GNUNET_CONTAINER_MultiPeerMap * addresses,
447 struct ATS_Address *address)
449 ph.env.sf.s_address_update_property (solver, address, GNUNET_ATS_QUALITY_NET_DELAY,
451 (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100))
454 ph.env.sf.s_address_update_property (solver, address,
455 GNUNET_ATS_QUALITY_NET_DISTANCE, 10,
456 (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100))
461 * Update a certain percentage of peers
463 * @param cp the current number of peers
464 * @param ca the current number of addresses
465 * @param percentage_peers the percentage of peers to update
469 perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers)
471 struct ATS_Address *cur_address;
480 count = cp * ((double) percentage_peers / 100);
481 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
482 "Updating %u of %u peers \n", count, cp);
484 for (c_peer = 0; c_peer < cp; c_peer++)
489 while (c_select < count)
491 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, cp);
495 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
496 "Updating peer [%u] \n", r);
500 for (c_cur_p = 0; c_cur_p < cp; c_cur_p++)
504 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, ca);
505 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
506 "Updating peer [%u] address [%u]\n", c_cur_p, r);
509 for (cur_address = ph.peers[c_cur_p].head; NULL != cur_address; cur_address = cur_address->next)
512 perf_update_address (cur_address);
520 * Create an address for a peer
522 * @param cp index of the peer
523 * @param ca index of the address
524 * @return the address
526 static struct ATS_Address *
527 perf_create_address (int cp, int ca)
529 struct ATS_Address *a;
530 a = create_address (&ph.peers[cp].id,
531 "Test 1", "test 1", strlen ("test 1") + 1, 0);
532 GNUNET_CONTAINER_DLL_insert (ph.peers[cp].head, ph.peers[cp].tail, a);
533 GNUNET_CONTAINER_multipeermap_put (ph.addresses, &ph.peers[cp].id, a,
534 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
540 * Information callback for the solver
542 * @param op the solver operation
543 * @param stat status of the solver operation
544 * @param add additional solver information
547 solver_info_cb (void *cls,
548 enum GAS_Solver_Operation op,
549 enum GAS_Solver_Status stat,
550 enum GAS_Solver_Additional_Information add)
555 add_info = "GAS_INFO_NONE";
558 add_info = "GAS_INFO_MLP_FULL";
560 case GAS_INFO_UPDATED:
561 add_info = "GAS_INFO_MLP_UPDATED";
563 case GAS_INFO_PROP_ALL:
564 add_info = "GAS_INFO_PROP_ALL";
566 case GAS_INFO_PROP_SINGLE:
567 add_info = "GAS_INFO_PROP_SINGLE";
570 add_info = "INVALID";
577 case GAS_OP_SOLVE_START:
578 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
579 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
580 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
581 if (GNUNET_NO == ph.expecting_solution)
583 /* We do not expect a solution at the moment */
588 if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result))
590 /* Create new result */
591 tmp = GNUNET_new (struct Result);
592 ph.current_result = tmp;
593 ph.iterations_results[ph.current_iteration-1].results_array[ph.current_p -1] = tmp;
594 GNUNET_CONTAINER_DLL_insert_tail(ph.iterations_results[ph.current_iteration-1].result_head,
595 ph.iterations_results[ph.current_iteration-1].result_tail, tmp);
596 ph.current_result->addresses = ph.current_a;
597 ph.current_result->peers = ph.current_p;
598 ph.current_result->s_total = GNUNET_TIME_absolute_get();
599 ph.current_result->d_total = GNUNET_TIME_UNIT_FOREVER_REL;
600 ph.current_result->d_setup = GNUNET_TIME_UNIT_FOREVER_REL;
601 ph.current_result->d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
602 ph.current_result->d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
603 ph.current_result->info = add;
604 if ((add == GAS_INFO_UPDATED) || (GNUNET_YES == ph.performed_update))
606 ph.current_result->update = GNUNET_YES;
610 ph.current_result->update = GNUNET_NO;
615 case GAS_OP_SOLVE_STOP:
616 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
617 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
618 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
619 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
621 /* We do not expect a solution at the moment */
626 if (GAS_STAT_SUCCESS == stat)
627 ph.current_result->valid = GNUNET_YES;
629 ph.current_result->valid = GNUNET_NO;
631 if (NULL != ph.current_result)
633 /* Finalize result */
634 ph.current_result->e_total = GNUNET_TIME_absolute_get ();
635 ph.current_result->d_total = GNUNET_TIME_absolute_get_difference (
636 ph.current_result->s_total, ph.current_result->e_total);
638 ph.current_result = NULL;
641 case GAS_OP_SOLVE_SETUP_START:
642 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
643 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
644 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
645 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
651 if (GAS_STAT_SUCCESS == stat)
652 ph.current_result->valid = GNUNET_YES;
654 ph.current_result->valid = GNUNET_NO;
656 ph.current_result->s_setup = GNUNET_TIME_absolute_get ();
659 case GAS_OP_SOLVE_SETUP_STOP:
660 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
661 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
662 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
663 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
669 if (GAS_STAT_SUCCESS == stat)
670 ph.current_result->valid = GNUNET_YES;
672 ph.current_result->valid = GNUNET_NO;
674 ph.current_result->e_setup = GNUNET_TIME_absolute_get ();
675 ph.current_result->d_setup = GNUNET_TIME_absolute_get_difference (
676 ph.current_result->s_setup, ph.current_result->e_setup);
679 case GAS_OP_SOLVE_MLP_LP_START:
680 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
681 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
682 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
683 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
689 if (GAS_STAT_SUCCESS == stat)
690 ph.current_result->valid = GNUNET_YES;
692 ph.current_result->valid = GNUNET_NO;
694 ph.current_result->s_lp = GNUNET_TIME_absolute_get ();
696 case GAS_OP_SOLVE_MLP_LP_STOP:
697 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
698 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
699 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
700 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
706 if (GAS_STAT_SUCCESS == stat)
707 ph.current_result->valid = GNUNET_YES;
709 ph.current_result->valid = GNUNET_NO;
711 ph.current_result->e_lp = GNUNET_TIME_absolute_get ();
712 ph.current_result->d_lp = GNUNET_TIME_absolute_get_difference (
713 ph.current_result->s_lp, ph.current_result->e_lp);
716 case GAS_OP_SOLVE_MLP_MLP_START:
717 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
718 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
719 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
720 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
726 if (GAS_STAT_SUCCESS == stat)
727 ph.current_result->valid = GNUNET_YES;
729 ph.current_result->valid = GNUNET_NO;
731 ph.current_result->s_mlp = GNUNET_TIME_absolute_get ();
733 case GAS_OP_SOLVE_MLP_MLP_STOP:
734 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
735 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
736 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
737 if ((GNUNET_NO == ph.expecting_solution) || (NULL == ph.current_result))
743 if (GAS_STAT_SUCCESS == stat)
744 ph.current_result->valid = GNUNET_YES;
746 ph.current_result->valid = GNUNET_NO;
748 ph.current_result->e_mlp = GNUNET_TIME_absolute_get ();
749 ph.current_result->d_mlp = GNUNET_TIME_absolute_get_difference (
750 ph.current_result->s_mlp, ph.current_result->e_mlp);
752 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
753 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
754 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
755 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
757 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
758 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
759 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
760 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
761 if (GAS_STAT_SUCCESS != stat)
763 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
764 "Solver `%s' failed to update problem with %u peers and %u address!\n",
765 ph.ats_string, ph.current_p, ph.current_a);
775 * Evaluate results for a specific iteration
777 * @param iteration the iteration to evaluate
780 evaluate (int iteration)
782 struct GNUNET_DISK_FileHandle *f_full;
783 struct GNUNET_DISK_FileHandle *f_update;
785 char * data_fn_update;
789 struct Result *cur_res;
801 if (ph.create_datafile)
804 GNUNET_asprintf (&iter_text, "%s", "avg");
806 GNUNET_asprintf (&iter_text, "%u", iteration);
807 GNUNET_asprintf (&data_fn_full,
808 "perf_%s_full_%s_%u_%u_%u.data",
814 GNUNET_free (iter_text);
815 f_full = GNUNET_DISK_file_open (data_fn_full,
816 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
817 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
820 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
821 "Cannot open gnuplot file `%s'\n",
823 GNUNET_free (data_fn_full);
826 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
827 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
828 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
829 "Cannot write data to log file `%s'\n",
833 data_fn_update = NULL;
834 if ((ph.create_datafile) && (GNUNET_YES == ph.measure_updates))
837 GNUNET_asprintf (&iter_text, "%s", "avg");
839 GNUNET_asprintf (&iter_text, "%u", iteration);
840 GNUNET_asprintf (&data_fn_update, "perf_%s_update_i%u_%u_%u_%u.data",
846 GNUNET_free (iter_text);
847 f_update = GNUNET_DISK_file_open (data_fn_update,
848 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
849 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
850 if (NULL == f_update)
852 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
853 "Cannot open gnuplot file `%s'\n", data_fn_update);
854 GNUNET_free (data_fn_update);
856 GNUNET_DISK_file_close (f_full);
857 GNUNET_free (data_fn_full);
860 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
861 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
862 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
863 "Cannot write data to log file `%s'\n",
867 next = ph.iterations_results[ph.current_iteration -1].result_head;
868 while (NULL != (cur = next))
877 if (GNUNET_NO == cur->update)
879 cur_res = &ph.averaged_full_result[cur->peers - ph.N_peers_start];
883 cur_res = &ph.averaged_update_result[cur->peers - ph.N_peers_start];
886 cur_res->peers = cur->peers;
887 cur_res->addresses = cur->addresses;
888 cur_res->update = cur->update;
890 if (GNUNET_NO == cur->valid)
893 "Total time to solve %s for %u peers %u addresses: %s\n",
894 (GNUNET_YES == cur->update) ? "updated" : "full",
895 cur->peers, cur->addresses, "Failed to solve!");
901 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
903 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_total.rel_value_us)
904 cur_res->d_total.rel_value_us = 0;
905 if (GNUNET_YES == cur->valid)
906 cur_res->d_total.rel_value_us += cur->d_total.rel_value_us;
908 "Total time to solve %s for %u peers %u addresses: %llu us\n",
909 (GNUNET_YES == cur->update) ? "updated" : "full",
910 cur->peers, cur->addresses,
911 (unsigned long long) cur->d_total.rel_value_us);
912 GNUNET_asprintf(&str_d_total,
913 "%llu", (unsigned long long) cur->d_total.rel_value_us);
916 GNUNET_asprintf(&str_d_total, "-1");
917 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us)
919 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_setup.rel_value_us)
920 cur_res->d_setup.rel_value_us = 0;
921 if (GNUNET_YES == cur->valid)
922 cur_res->d_setup.rel_value_us += cur->d_setup.rel_value_us;
923 fprintf (stderr, "Total time to setup %s %u peers %u addresses: %llu us\n",
924 (GNUNET_YES == cur->update) ? "updated" : "full",
925 cur->peers, cur->addresses,
926 (unsigned long long) cur->d_setup.rel_value_us);
927 GNUNET_asprintf(&str_d_setup, "%llu",
928 (unsigned long long )cur->d_setup.rel_value_us);
931 GNUNET_asprintf(&str_d_setup, "-1");
933 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us)
935 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_lp.rel_value_us)
936 cur_res->d_lp.rel_value_us = 0;
937 if (GNUNET_YES == cur->valid)
938 cur_res->d_lp.rel_value_us += cur->d_lp.rel_value_us;
940 "Total time to solve %s LP for %u peers %u addresses: %llu us\n",
941 (GNUNET_YES == cur->update) ? "updated" : "full",
944 (unsigned long long )cur->d_lp.rel_value_us);
945 GNUNET_asprintf (&str_d_lp,
946 "%llu", (unsigned long long )cur->d_lp.rel_value_us);
949 GNUNET_asprintf (&str_d_lp, "-1");
951 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us)
953 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == cur_res->d_mlp.rel_value_us)
954 cur_res->d_mlp.rel_value_us = 0;
955 if (GNUNET_YES == cur->valid)
956 cur_res->d_mlp.rel_value_us += cur->d_mlp.rel_value_us;
958 fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n",
959 (GNUNET_YES == cur->update) ? "updated" : "full",
960 cur->peers, cur->addresses,
961 (unsigned long long )cur->d_mlp.rel_value_us);
962 GNUNET_asprintf (&str_d_mlp,
963 "%llu", (unsigned long long )cur->d_mlp.rel_value_us);
966 GNUNET_asprintf (&str_d_mlp, "-1");
969 if (GNUNET_YES == ph.create_datafile)
972 GNUNET_asprintf (&data,
973 "%u;%u;%s;%s;%s;%s\n",
974 cur->peers, cur->addresses,
979 if (cur->update == GNUNET_NO)
981 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data)))
982 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
983 "Cannot write data to log file `%s'\n",
986 if ((cur->update == GNUNET_YES) && (NULL != f_update))
988 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
989 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
990 "Cannot write data to log file `%s'\n",
995 GNUNET_free_non_null (str_d_total);
996 GNUNET_free_non_null (str_d_setup);
997 GNUNET_free_non_null (str_d_lp);
998 GNUNET_free_non_null (str_d_mlp);
1000 GNUNET_CONTAINER_DLL_remove (ph.iterations_results[ph.current_iteration-1].result_head,
1001 ph.iterations_results[ph.current_iteration-1].result_tail, cur);
1002 //GNUNET_free (cur);
1005 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1006 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1008 GNUNET_free_non_null (data_fn_full);
1010 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1011 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1013 GNUNET_free_non_null (data_fn_update);
1017 * Evaluate average results for all iterations
1020 evaluate_average (void)
1025 struct GNUNET_DISK_FileHandle *f_full;
1026 struct GNUNET_DISK_FileHandle *f_update;
1028 char * data_fn_full;
1029 char * data_fn_update;
1040 data_fn_full = NULL;
1042 if (ph.create_datafile)
1044 GNUNET_asprintf (&data_fn_full,
1045 "perf_%s_full_avg_%u-%u_%u_%u.data",
1047 ph.total_iterations,
1051 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1052 "Using data file `%s'\n",
1055 f_full = GNUNET_DISK_file_open (data_fn_full,
1056 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
1057 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
1060 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1061 "Cannot open gnuplot file `%s'\n",
1063 GNUNET_free (data_fn_full);
1067 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1068 "Using update data file `%s'\n",
1071 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1072 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data)))
1073 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1074 "Cannot write data to log file `%s'\n",
1078 data_fn_update = NULL;
1079 if ((ph.create_datafile) && (GNUNET_YES == ph.measure_updates))
1081 GNUNET_asprintf (&data_fn_update, "perf_%s_update_avg_%u-%u_%u_%u.data",
1083 ph.total_iterations,
1087 f_update = GNUNET_DISK_file_open (data_fn_update,
1088 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
1089 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
1090 if (NULL == f_update)
1092 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1093 "Cannot open gnuplot file `%s'\n", data_fn_update);
1094 GNUNET_free (data_fn_update);
1096 GNUNET_DISK_file_close (f_full);
1097 GNUNET_free (data_fn_full);
1101 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1102 "Using update data file `%s'\n",
1105 data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n";
1106 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1108 "Cannot write data to log file `%s'\n",
1113 for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++)
1117 GNUNET_asprintf(&data_str, "%u;%u",c_peer, ph.N_address);
1118 for (c_iteration = 0; c_iteration < ph.total_iterations; c_iteration ++)
1120 struct Result *cur_res;
1122 cur_res = ph.iterations_results[c_iteration].results_array[c_peer -1];
1123 fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses);
1124 fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us);
1126 data_tmp = GNUNET_strdup (data_str);
1127 GNUNET_free (data_str);
1128 GNUNET_asprintf (&data_str, "%s;%llu", data_tmp, cur_res->d_total.rel_value_us);
1129 GNUNET_free (data_tmp);
1131 data_tmp = GNUNET_strdup (data_str);
1132 GNUNET_free (data_str);
1133 GNUNET_asprintf (&data_str, "%s\n", data_tmp);
1134 GNUNET_free (data_tmp);
1136 fprintf (stderr, "Result: %s\n", data_str);
1137 GNUNET_DISK_file_write (f_full, data_str, strlen(data_str));
1138 GNUNET_free (data_str);
1142 if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full)))
1143 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1145 GNUNET_free_non_null (data_fn_full);
1147 if ((NULL != f_update) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_update)))
1148 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
1150 GNUNET_free_non_null (data_fn_update);
1153 for (c_o = 0; c_o < 2; c_o++)
1157 "Duration for a full solution averaged over %i iterations\n",
1158 ph.total_iterations);
1161 "Duration for a full solution averaged over %i iterations\n",
1162 ph.total_iterations);
1164 for (c_i = 0; c_i <= ph.N_peers_end - ph.N_peers_start; c_i++)
1168 cur = &ph.averaged_full_result[c_i];
1170 else if ((GNUNET_YES == ph.measure_updates) && (1 == c_o))
1172 cur = &ph.averaged_update_result[c_i];
1177 if (0 == cur->peers)
1185 if (0 >= cur->valid)
1188 "No valid results for %s for %u peers %u addresses!\n",
1189 (GNUNET_YES == cur->update) ? "updated" : "full",
1190 cur->peers, cur->addresses);
1194 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
1197 "Average total time from %u iterations to solve %s for %u peers %u addresses: %llu us\n",
1199 (GNUNET_YES == cur->update) ? "updated" : "full",
1200 cur->peers, cur->addresses,
1201 (unsigned long long) cur->d_total.rel_value_us / cur->valid);
1202 GNUNET_asprintf(&str_d_total, "%llu",
1203 (unsigned long long) cur->d_total.rel_value_us / cur->valid);
1206 GNUNET_asprintf (&str_d_total, "-1");
1208 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us)
1211 "Average total time from %u iterations to setup for %u peers %u addresses: %llu us\n",
1212 cur->valid, cur->peers, cur->addresses,
1213 (unsigned long long) cur->d_setup.rel_value_us / cur->valid);
1214 GNUNET_asprintf(&str_d_setup, "%llu",
1215 (unsigned long long) cur->d_setup.rel_value_us / cur->valid);
1219 GNUNET_asprintf (&str_d_setup, "-1");
1221 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us)
1224 "Average total time from %u iterations to solve lp %s for %u peers %u addresses: %llu us\n",
1226 (GNUNET_YES == cur->update) ? "updated" : "full",
1227 cur->peers, cur->addresses,
1228 (unsigned long long) cur->d_lp.rel_value_us / cur->valid);
1229 GNUNET_asprintf(&str_d_lp, "%llu",
1230 (unsigned long long) cur->d_lp.rel_value_us / ph.total_iterations);
1233 GNUNET_asprintf (&str_d_lp, "-1");
1235 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us)
1238 "Average total time from %u iterations to solve mlp %s for %u peers %u addresses: %llu us\n",
1240 (GNUNET_YES == cur->update) ? "updated" : "full",
1241 cur->peers, cur->addresses,
1242 (unsigned long long) cur->d_mlp.rel_value_us / cur->valid);
1243 GNUNET_asprintf(&str_d_mlp, "%llu",
1244 (unsigned long long) cur->d_mlp.rel_value_us / cur->valid);
1247 GNUNET_asprintf (&str_d_mlp, "-1");
1250 if (GNUNET_YES == ph.create_datafile)
1252 GNUNET_asprintf (&data,
1253 "%u;%u;%s;%s;%s;%s\n",
1254 cur->peers, cur->addresses,
1259 if (cur->update == GNUNET_NO)
1261 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data)))
1262 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1263 "Cannot write data to log file `%s'\n",
1266 if ((cur->update == GNUNET_YES) && (NULL != f_update))
1268 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data)))
1269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1270 "Cannot write data to log file `%s'\n",
1276 GNUNET_free_non_null (str_d_total);
1277 GNUNET_free_non_null (str_d_setup);
1278 GNUNET_free_non_null (str_d_lp);
1279 GNUNET_free_non_null (str_d_mlp);
1287 * Run a performance iteration
1291 perf_run_iteration (void)
1293 struct ATS_Address *cur;
1294 struct ATS_Address *next;
1297 int count_p = ph.N_peers_end;
1298 int count_a = ph.N_address;
1299 struct ATS_Address * cur_addr;
1302 ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p) * sizeof (struct Result *));
1303 ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer));
1304 for (cp = 0; cp < count_p; cp++)
1305 perf_create_peer (cp);
1306 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1307 "Iteration %u of %u, added %u peers\n", ph.current_iteration, ph.total_iterations, cp);
1309 for (cp = 0; cp < count_p; cp++)
1311 if (GNUNET_NO == ph.bulk_running)
1313 ph.bulk_running = GNUNET_YES;
1314 ph.env.sf.s_bulk_start (ph.solver);
1316 ph.current_p = cp + 1;
1317 for (ca = 0; ca < count_a; ca++)
1319 cur_addr = perf_create_address (cp, ca);
1321 uint32_t net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1);
1322 cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information);
1323 cur_addr->atsi_count = 1;
1324 cur_addr->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
1325 cur_addr->atsi[0].value = htonl (net);
1326 ph.env.sf.s_add (ph.solver, cur_addr, net);
1328 ph.current_a = ca + 1;
1329 perf_address_initial_update (ph.solver, ph.addresses, cur_addr);
1330 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1331 "Adding address for peer %u address %u\n", cp, ca);
1333 /* Notify solver about request */
1334 ph.env.sf.s_get (ph.solver, &ph.peers[cp].id);
1336 if (cp + 1 >= ph.N_peers_start)
1338 /* Disable bulk to solve the problem */
1339 if (GNUNET_YES == ph.bulk_running)
1341 ph.expecting_solution = GNUNET_YES;
1342 ph.bulk_running = GNUNET_NO;
1343 ph.env.sf.s_bulk_stop (ph.solver);
1348 /* Problem is solved by the solver here due to unlocking */
1349 ph.expecting_solution = GNUNET_NO;
1351 /* Update the problem */
1352 if ((0 < ph.opt_update_percent) && (GNUNET_YES == ph.measure_updates))
1355 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1356 "Updating problem with %u peers and %u addresses\n", cp + 1, ca);
1358 ph.expecting_solution = GNUNET_YES;
1359 ph.performed_update = GNUNET_YES;
1360 if (GNUNET_NO == ph.bulk_running)
1362 ph.bulk_running = GNUNET_YES;
1363 ph.env.sf.s_bulk_start (ph.solver);
1365 perf_update_all_addresses (cp + 1, ca, ph.opt_update_percent);
1366 ph.bulk_running = GNUNET_NO;
1367 ph.env.sf.s_bulk_stop (ph.solver);
1368 /* Problem is solved by the solver here due to unlocking */
1369 ph.performed_update = GNUNET_NO;
1370 ph.expecting_solution = GNUNET_NO;
1372 GNUNET_assert (GNUNET_NO == ph.bulk_running);
1376 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1377 "Done, cleaning up addresses\n");
1378 if (GNUNET_NO == ph.bulk_running)
1380 ph.env.sf.s_bulk_start (ph.solver);
1381 ph.bulk_running = GNUNET_YES;
1384 for (cp = 0; cp < count_p; cp++)
1386 for (cur = ph.peers[cp].head; cur != NULL ; cur = next)
1388 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1389 "Deleting addresses for peer %u\n", cp);
1390 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (ph.addresses,
1391 &ph.peers[cp].id, cur));
1392 ph.env.sf.s_del (ph.solver, cur, GNUNET_NO);
1394 GNUNET_CONTAINER_DLL_remove(ph.peers[cp].head, ph.peers[cp].tail, cur);
1395 GNUNET_free_non_null (cur->atsi);
1400 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1401 "Iteration done\n");
1402 GNUNET_free(ph.peers);
1407 run (void *cls, char * const *args, const char *cfgfile,
1408 const struct GNUNET_CONFIGURATION_Handle *cfg)
1410 GNUNET_log_setup ("perf-ats-solver", "WARNING", NULL);
1412 char *src_filename = GNUNET_strdup (__FILE__);
1413 char *test_filename = cls;
1416 struct GNUNET_CONFIGURATION_Handle *solver_cfg;
1417 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
1418 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
1422 /* Extract test name */
1423 if (NULL == (sep = (strstr (src_filename,".c"))))
1425 GNUNET_free (src_filename);
1432 if (NULL != (sep = strstr (test_filename, ".exe")))
1435 if (NULL == (solver = strstr (test_filename, src_filename)))
1437 GNUNET_free (src_filename);
1442 solver += strlen (src_filename) +1;
1444 if (0 == strcmp(solver, "proportional"))
1446 ph.ats_mode = MODE_PROPORTIONAL;
1447 ph.ats_string = "proportional";
1449 else if (0 == strcmp(solver, "mlp"))
1451 ph.ats_mode = MODE_MLP;
1452 ph.ats_string = "mlp";
1454 else if ((0 == strcmp(solver, "ril")))
1456 ph.ats_mode = MODE_RIL;
1457 ph.ats_string = "ril";
1461 GNUNET_free (src_filename);
1466 GNUNET_free (src_filename);
1468 /* Calculcate peers */
1469 if ((0 == ph.N_peers_start) && (0 == ph.N_peers_end))
1471 ph.N_peers_start = DEFAULT_PEERS_START;
1472 ph.N_peers_end = DEFAULT_PEERS_END;
1474 if (0 == ph.N_address)
1475 ph.N_address = DEFAULT_ADDRESSES;
1477 if (ph.N_peers_start != ph.N_peers_end)
1478 fprintf (stderr, "Benchmarking solver `%s' with %u to %u peers and %u addresses in %u iterations\n",
1479 ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address, ph.total_iterations);
1481 fprintf (stderr, "Benchmarking solver `%s' with %u peers and %u addresses in %u iterations\n",
1482 ph.ats_string, ph.N_peers_end, ph.N_address, ph.total_iterations);
1484 if (0 == ph.opt_update_percent)
1485 ph.opt_update_percent = DEFAULT_UPDATE_PERCENTAGE;
1488 solver_cfg = GNUNET_CONFIGURATION_create();
1489 if ((NULL == solver_cfg) || (GNUNET_SYSERR == (GNUNET_CONFIGURATION_load ( solver_cfg, "perf_ats_solver.conf"))))
1495 if (GNUNET_ATS_NetworkTypeCount != load_quotas (solver_cfg,
1496 quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
1503 /* Create array of DLL to store results for iterations */
1504 ph.iterations_results = GNUNET_malloc (sizeof (struct Iteration) * ph.total_iterations);
1505 ph.averaged_full_result = GNUNET_malloc (sizeof (struct Result) * ((ph.N_peers_end + 1) - ph.N_peers_start));
1506 for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++)
1508 ph.averaged_full_result[c].d_setup = GNUNET_TIME_UNIT_FOREVER_REL;
1509 ph.averaged_full_result[c].d_total = GNUNET_TIME_UNIT_FOREVER_REL;
1510 ph.averaged_full_result[c].d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
1511 ph.averaged_full_result[c].d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
1513 ph.averaged_update_result = GNUNET_malloc (sizeof (struct Result) * ((ph.N_peers_end + 1) - ph.N_peers_start));
1514 for (c = 0; c <= ph.N_peers_end - ph.N_peers_start; c++)
1516 ph.averaged_update_result[c].d_setup = GNUNET_TIME_UNIT_FOREVER_REL;
1517 ph.averaged_update_result[c].d_total = GNUNET_TIME_UNIT_FOREVER_REL;
1518 ph.averaged_update_result[c].d_lp = GNUNET_TIME_UNIT_FOREVER_REL;
1519 ph.averaged_update_result[c].d_mlp = GNUNET_TIME_UNIT_FOREVER_REL;
1523 ph.env.cfg = solver_cfg;
1524 ph.stat = GNUNET_STATISTICS_create ("ats", cfg);
1525 ph.env.stats = ph.stat;
1526 ph.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
1527 ph.env.addresses = ph.addresses;
1528 ph.env.bandwidth_changed_cb = bandwidth_changed_cb;
1529 ph.env.get_preferences = &get_preferences_cb;
1530 ph.env.get_property = &get_property_cb;
1531 ph.env.network_count = GNUNET_ATS_NetworkTypeCount;
1532 ph.env.info_cb = &solver_info_cb;
1533 ph.env.info_cb_cls = NULL;
1535 int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
1536 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1538 ph.env.networks[c] = networks[c];
1539 ph.env.out_quota[c] = quotas_out[c];
1540 ph.env.in_quota[c] = quotas_in[c];
1541 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loading network quotas: `%s' %llu %llu \n",
1542 GNUNET_ATS_print_network_type(ph.env.networks[c]),
1543 ph.env.out_quota[c],
1544 ph.env.in_quota[c]);
1546 GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL );
1548 GNUNET_asprintf (&plugin, "libgnunet_plugin_ats_%s", ph.ats_string);
1549 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s'\n"), ph.ats_string);
1550 if (NULL == (ph.solver = GNUNET_PLUGIN_load (plugin, &ph.env)))
1552 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize solver `%s'!\n"), plugin);
1557 /* Do the benchmark */
1558 for (ph.current_iteration = 1; ph.current_iteration <= ph.total_iterations; ph.current_iteration++)
1560 fprintf (stderr, "Iteration %u of %u starting\n", ph.current_iteration, ph.total_iterations);
1561 perf_run_iteration ();
1562 evaluate (ph.current_iteration);
1563 fprintf (stderr, "Iteration %u of %u done\n", ph.current_iteration, ph.total_iterations);
1565 evaluate_average ();
1568 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string);
1569 GNUNET_PLUGIN_unload (plugin, ph.solver);
1570 GNUNET_free (plugin);
1571 for (c = 0; c < ph.total_iterations; c++ )
1573 for (c2 = ph.N_peers_start; c2 < ph.N_peers_end; c2++ )
1575 GNUNET_free (ph.iterations_results[c].results_array[c2]);
1577 GNUNET_free(ph.iterations_results[c].results_array);
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 function of the benchmark
1591 * @param argc argument count
1592 * @param argv argument values
1595 main (int argc, char *argv[])
1597 /* extract command line arguments */
1598 ph.opt_update_percent = 0;
1599 ph.N_peers_start = 0;
1602 ph.ats_string = NULL;
1603 ph.create_datafile = GNUNET_NO;
1604 ph.measure_updates = GNUNET_NO;
1605 ph.total_iterations = 1;
1607 static struct GNUNET_GETOPT_CommandLineOption options[] = {
1608 { 'a', "addresses", NULL,
1609 gettext_noop ("addresses to use"),
1610 1, &GNUNET_GETOPT_set_uint, &ph.N_address },
1611 { 's', "start", NULL,
1612 gettext_noop ("start with peer"),
1613 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_start },
1615 gettext_noop ("end with peer"),
1616 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end },
1617 { 'i', "iterations", NULL,
1618 gettext_noop ("number of iterations used for averaging (default: 1)"),
1619 1, &GNUNET_GETOPT_set_uint, &ph.total_iterations },
1620 { 'p', "percentage", NULL,
1621 gettext_noop ("update a fix percentage of addresses"),
1622 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },
1623 { 'd', "data", NULL,
1624 gettext_noop ("create data file"),
1625 0, &GNUNET_GETOPT_set_one, &ph.create_datafile},
1626 { 'u', "update", NULL,
1627 gettext_noop ("measure updates"),
1628 0, &GNUNET_GETOPT_set_one, &ph.measure_updates},
1629 GNUNET_GETOPT_OPTION_END
1632 GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]);
1636 /* end of file perf_ats_solver.c */