aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats_solver.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-28 09:30:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-28 09:30:07 +0000
commite4d89c9377aef71f0460d1ee1dcaaa6aa4ef6a05 (patch)
tree7cd545b153fdb94ce4bde48c1ca8a8c5604bcd17 /src/ats/perf_ats_solver.c
parentc0a74f813e2ec60f271e5da6db2980343ab9fedb (diff)
downloadgnunet-e4d89c9377aef71f0460d1ee1dcaaa6aa4ef6a05.tar.gz
gnunet-e4d89c9377aef71f0460d1ee1dcaaa6aa4ef6a05.zip
more documentation and minor cleanups
Diffstat (limited to 'src/ats/perf_ats_solver.c')
-rw-r--r--src/ats/perf_ats_solver.c92
1 files changed, 68 insertions, 24 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c
index 4ad93e0ba..c42ddf44b 100644
--- a/src/ats/perf_ats_solver.c
+++ b/src/ats/perf_ats_solver.c
@@ -116,10 +116,13 @@ struct PerfHandle
116 struct Iteration *iterations_results; 116 struct Iteration *iterations_results;
117 117
118 /** 118 /**
119 * Array to store averaged result with length #peers 119 * Array to store averaged full solution result with length #peers
120 */ 120 */
121 struct Result *averaged_full_result; 121 struct Result *averaged_full_result;
122 122
123 /**
124 * Array to store averaged updated solution result with length #peers
125 */
123 struct Result *averaged_update_result; 126 struct Result *averaged_update_result;
124 127
125 /** 128 /**
@@ -127,7 +130,14 @@ struct PerfHandle
127 */ 130 */
128 struct Result *current_result; 131 struct Result *current_result;
129 132
133 /**
134 * Current number of peers benchmarked
135 */
130 int current_p; 136 int current_p;
137
138 /**
139 * Current number of addresses benchmarked
140 */
131 int current_a; 141 int current_a;
132 142
133 /** 143 /**
@@ -347,6 +357,10 @@ static struct PerfHandle ph;
347 */ 357 */
348static int ret; 358static int ret;
349 359
360
361/**
362 * Do shutdown
363 */
350static void 364static void
351end_now (int res) 365end_now (int res)
352{ 366{
@@ -355,23 +369,22 @@ end_now (int res)
355 GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO); 369 GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO);
356 ph.stat = NULL; 370 ph.stat = NULL;
357 } 371 }
358 /* 372
359 if (NULL != addresses) 373 GNUNET_free_non_null (ph.peers);
360 { 374 GNUNET_free_non_null (ph.iterations_results);
361 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL); 375 GNUNET_free_non_null (ph.averaged_full_result);
362 GNUNET_CONTAINER_multihashmap_destroy (addresses); 376 GNUNET_free_non_null (ph.averaged_update_result);
363 addresses = NULL ;
364 }*/
365 if (NULL != ph.peers)
366 {
367 GNUNET_free(ph.peers);
368 }
369 377
370 GAS_normalization_stop (); 378 GAS_normalization_stop ();
371 ret = res; 379 ret = res;
372} 380}
373 381
374 382
383/**
384 * Create a peer used for benchmarking
385 *
386 * @param cp the number of the peer
387 */
375static void 388static void
376perf_create_peer (int cp) 389perf_create_peer (int cp)
377{ 390{
@@ -383,7 +396,11 @@ perf_create_peer (int cp)
383} 396}
384 397
385 398
386 399/**
400 * Perform an update for an address
401 *
402 * @param cur the address to update
403 */
387static void 404static void
388perf_update_address (struct ATS_Address *cur) 405perf_update_address (struct ATS_Address *cur)
389{ 406{
@@ -475,6 +492,14 @@ perf_address_initial_update (void *solver,
475 / 100); 492 / 100);
476} 493}
477 494
495/**
496 * Update a certain percentage of peers
497 *
498 * @param cp the current number of peers
499 * @param ca the current number of addresses
500 * @param percentage_peers the percentage of peers to update
501 */
502
478static void 503static void
479perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers) 504perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percentage_peers)
480{ 505{
@@ -520,14 +545,19 @@ perf_update_all_addresses (unsigned int cp, unsigned int ca, unsigned int percen
520 { 545 {
521 if (c_cur_a == r) 546 if (c_cur_a == r)
522 perf_update_address (cur_address); 547 perf_update_address (cur_address);
523
524 c_cur_a ++; 548 c_cur_a ++;
525 } 549 }
526 } 550 }
527 } 551 }
528} 552}
529 553
530 554/**
555 * Create an address for a peer
556 *
557 * @param cp index of the peer
558 * @param ca index of the address
559 * @return the address
560 */
531static struct ATS_Address * 561static struct ATS_Address *
532perf_create_address (int cp, int ca) 562perf_create_address (int cp, int ca)
533{ 563{
@@ -540,6 +570,14 @@ perf_create_address (int cp, int ca)
540 return a; 570 return a;
541} 571}
542 572
573
574/**
575 * Information callback for the solver
576 *
577 * @param op the solver operation
578 * @param stat status of the solver operation
579 * @param add additional solver information
580 */
543static void 581static void
544solver_info_cb (void *cls, 582solver_info_cb (void *cls,
545 enum GAS_Solver_Operation op, 583 enum GAS_Solver_Operation op,
@@ -883,7 +921,6 @@ write_gnuplot_script (char * data_fn, int iteration, int full)
883 * 921 *
884 * @param iteration the iteration to evaluate 922 * @param iteration the iteration to evaluate
885 */ 923 */
886
887static void 924static void
888evaluate (int iteration) 925evaluate (int iteration)
889{ 926{
@@ -1116,7 +1153,9 @@ evaluate (int iteration)
1116 GNUNET_free_non_null (data_fn_update); 1153 GNUNET_free_non_null (data_fn_update);
1117} 1154}
1118 1155
1119 1156/**
1157 * Evaluate average results for all iterations
1158 */
1120static void 1159static void
1121evaluate_average (void) 1160evaluate_average (void)
1122{ 1161{
@@ -1210,11 +1249,9 @@ evaluate_average (void)
1210 "No valid results for %s for %u peers %u addresses!\n", 1249 "No valid results for %s for %u peers %u addresses!\n",
1211 (GNUNET_YES == cur->update) ? "updated" : "full", 1250 (GNUNET_YES == cur->update) ? "updated" : "full",
1212 cur->peers, cur->addresses); 1251 cur->peers, cur->addresses);
1213
1214 continue; 1252 continue;
1215 } 1253 }
1216 1254
1217
1218 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) 1255 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us)
1219 { 1256 {
1220 fprintf (stderr, 1257 fprintf (stderr,
@@ -1314,8 +1351,12 @@ evaluate_average (void)
1314 GNUNET_free_non_null (data_fn_update); 1351 GNUNET_free_non_null (data_fn_update);
1315} 1352}
1316 1353
1354/**
1355 * Run a performance iteration
1356 */
1357
1317static void 1358static void
1318perf_run (void) 1359perf_run_iteration (void)
1319{ 1360{
1320 struct ATS_Address *cur; 1361 struct ATS_Address *cur;
1321 struct ATS_Address *next; 1362 struct ATS_Address *next;
@@ -1363,9 +1404,7 @@ perf_run (void)
1363 ph.env.sf.s_bulk_stop (ph.solver); 1404 ph.env.sf.s_bulk_stop (ph.solver);
1364 } 1405 }
1365 else 1406 else
1366 {
1367 GNUNET_break (0); 1407 GNUNET_break (0);
1368 }
1369 1408
1370 /* Problem is solved by the solver here due to unlocking */ 1409 /* Problem is solved by the solver here due to unlocking */
1371 ph.expecting_solution = GNUNET_NO; 1410 ph.expecting_solution = GNUNET_NO;
@@ -1568,7 +1607,7 @@ run (void *cls, char * const *args, const char *cfgfile,
1568 /* Do the benchmark */ 1607 /* Do the benchmark */
1569 for (ph.current_iteration = 1; ph.current_iteration <= ph.iterations; ph.current_iteration++) 1608 for (ph.current_iteration = 1; ph.current_iteration <= ph.iterations; ph.current_iteration++)
1570 { 1609 {
1571 perf_run (); 1610 perf_run_iteration ();
1572 evaluate (ph.current_iteration); 1611 evaluate (ph.current_iteration);
1573 } 1612 }
1574 evaluate_average (); 1613 evaluate_average ();
@@ -1585,6 +1624,12 @@ run (void *cls, char * const *args, const char *cfgfile,
1585 ph.solver = NULL; 1624 ph.solver = NULL;
1586} 1625}
1587 1626
1627/**
1628 * Main function of the benchmark
1629 *
1630 * @param argc argument count
1631 * @param argv argument values
1632 */
1588int 1633int
1589main (int argc, char *argv[]) 1634main (int argc, char *argv[])
1590{ 1635{
@@ -1624,7 +1669,6 @@ main (int argc, char *argv[])
1624 }; 1669 };
1625 1670
1626 GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]); 1671 GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]);
1627
1628 return ret; 1672 return ret;
1629} 1673}
1630 1674