aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-04-15 11:47:58 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-04-15 11:47:58 +0000
commit082a4ab779c24b591e2de1628805d7d36f0051bc (patch)
tree83a4032a26d8ff48e8b7fb2c92fec5f7ae639e39 /src/transport/test_transport_ats.c
parent02b8a113a9f6ef38b567cbfe52fc70c6a61437a7 (diff)
downloadgnunet-082a4ab779c24b591e2de1628805d7d36f0051bc.tar.gz
gnunet-082a4ab779c24b591e2de1628805d7d36f0051bc.zip
improvements for better benchmarking
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r--src/transport/test_transport_ats.c121
1 files changed, 83 insertions, 38 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index e83080a1a..27c0b65f5 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -49,6 +49,7 @@ static int peers_left;
49static int failed_peers; 49static int failed_peers;
50 50
51static int measurement_started = GNUNET_NO; 51static int measurement_started = GNUNET_NO;
52static char * config_file;
52 53
53static struct GNUNET_TESTING_PeerGroup *pg; 54static struct GNUNET_TESTING_PeerGroup *pg;
54 55
@@ -87,6 +88,7 @@ static int peers;
87static int force_q_updates; 88static int force_q_updates;
88static int force_rebuild; 89static int force_rebuild;
89static int send_msg; 90static int send_msg;
91static int machine_parsable;
90 92
91static struct TEST_result results_new [MEASUREMENTS+1]; 93static struct TEST_result results_new [MEASUREMENTS+1];
92static struct TEST_result results_modified [MEASUREMENTS+1]; 94static struct TEST_result results_modified [MEASUREMENTS+1];
@@ -198,62 +200,74 @@ static void shutdown_peers()
198static void evaluate_measurements() 200static void evaluate_measurements()
199{ 201{
200 int c; 202 int c;
201 double average ; 203 //int mechs = 0;
202 double stddev; 204 double average[3];
203 205 double stddev[3];
206 //char * output;
204 c = 1; 207 c = 1;
205 208
206 average = 0.0; 209 //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs,
210
211 average[0] = 0.0;
207 for (c=0; c<c_new;c++) 212 for (c=0; c<c_new;c++)
208 { 213 {
209 average += (double) results_new[c].duration; 214 average[0] += (double) results_new[c].duration;
210 } 215 }
211 average /= c_new; 216 average[0] /= c_new;
212 217
213 stddev = 0.0; 218 stddev[0] = 0.0;
214 for (c=0; c<c_new;c++) 219 for (c=0; c<c_new;c++)
215 { 220 {
216 stddev += (results_new[c].duration - average) * (results_new[c].duration - average); 221 stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]);
217 } 222 }
218 stddev /= c_new; 223 stddev[0] /= c_new;
219 stddev = sqrt (stddev); 224 stddev[0] = sqrt (stddev[0]);
220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new average: %f stddev: %f\n", average, stddev); 225 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"new, %i measurements, average: %f stddev: %f\n",
226 c_new, average[0], stddev[0]);
221 227
222 average = 0.0; 228 average[1] = 0.0;
223 for (c=0; c<c_modified;c++) 229 for (c=0; c<c_modified;c++)
224 { 230 {
225 average += (double) results_modified[c].duration; 231 average[1] += (double) results_modified[c].duration;
226 } 232 }
227 average /= c_modified; 233 average[1] /= c_modified;
228 234
229 stddev = 0.0; 235 stddev[1] = 0.0;
230 for (c=0; c<c_modified;c++) 236 for (c=0; c<c_modified;c++)
231 { 237 {
232 stddev += (results_modified[c].duration - average) * (results_modified[c].duration - average); 238 stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]);
233 } 239 }
234 stddev /= c_modified; 240 stddev[1] /= c_modified;
235 stddev = sqrt (stddev); 241 stddev[1] = sqrt (stddev[1]);
236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified average: %f stddev: %f\n", average, stddev); 242 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"modified, %i measurements, average: %f stddev: %f\n",
243 c_modified, average[1], stddev[1]);
237 244
238 average = 0.0; 245 average[2] = 0.0;
239 for (c=0; c<c_unmodified;c++) 246 for (c=0; c<c_unmodified;c++)
240 { 247 {
241 average += (double) results_unmodified[c].duration; 248 average[2] += (double) results_unmodified[c].duration;
242 } 249 }
243 average /= c_unmodified; 250 average[2] /= c_unmodified;
244 stddev = 0.0; 251 stddev[2] = 0.0;
245 for (c=0; c<c_unmodified;c++) 252 for (c=0; c<c_unmodified;c++)
246 { 253 {
247 stddev += (results_unmodified[c].duration - average) * (results_unmodified[c].duration - average); 254 stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]);
248 } 255 }
249 stddev /= c_unmodified; 256 stddev[2] /= c_unmodified;
250 stddev = sqrt (stddev); 257 stddev[2] = sqrt (stddev[2]);
251 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified average: %f stddev: %f\n", average, stddev); 258
252 259 if (!machine_parsable) GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"unmodified, %i measurements, average: %f stddev: %f\n",
253 260 c_unmodified, average[2], stddev[2]);
254 261
255 262 if (machine_parsable)
256 263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,",peers,%i,mechs,%i,"
264 "new,%i,%f,%f,"
265 "mod,%i,%f,%f,"
266 "unmod,%i,%f,%f\n",
267 peers-1, results_unmodified[0].mechs,
268 c_new, average[0], stddev[0],
269 c_modified, average[1], stddev[1],
270 c_unmodified, average[2], stddev[2]);
257 shutdown_peers(); 271 shutdown_peers();
258} 272}
259 273
@@ -310,6 +324,9 @@ int stats_cb (void *cls,
310 measurement_started = GNUNET_YES; 324 measurement_started = GNUNET_YES;
311 count = 1; 325 count = 1;
312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); 326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value);
327#if !VERBOSE
328 if (!machine_parsable) fprintf(stderr, "%i", count);
329#endif
313 } 330 }
314 331
315 if (measurement_started == GNUNET_YES) 332 if (measurement_started == GNUNET_YES)
@@ -367,9 +384,11 @@ int stats_cb (void *cls,
367 count ++; 384 count ++;
368 385
369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , MEASUREMENTS); 386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified , MEASUREMENTS);
370 if ((count > MEASUREMENTS * 4) || ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))) 387 if ((count > MEASUREMENTS * 5) || ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)))
371 { 388 {
372 fprintf(stdout, "\n"); 389#if !VERBOSE
390 if (!machine_parsable) fprintf(stdout, "\n");
391#endif
373 if (stats_task != GNUNET_SCHEDULER_NO_TASK) 392 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
374 { 393 {
375 GNUNET_SCHEDULER_cancel(stats_task); 394 GNUNET_SCHEDULER_cancel(stats_task);
@@ -381,6 +400,9 @@ int stats_cb (void *cls,
381 400
382 printed = GNUNET_NO; 401 printed = GNUNET_NO;
383 current.timestamp = value; 402 current.timestamp = value;
403#if !VERBOSE
404 if (!machine_parsable) fprintf(stderr, "..%i", count);
405#endif
384 return GNUNET_OK; 406 return GNUNET_OK;
385 } 407 }
386 } 408 }
@@ -628,7 +650,7 @@ check ()
628{ 650{
629 char *const argv[] = { "test-testing", 651 char *const argv[] = { "test-testing",
630 "-c", 652 "-c",
631 "test_transport_ats.conf", 653 config_file,
632#if VERBOSE 654#if VERBOSE
633 "-L", "DEBUG", 655 "-L", "DEBUG",
634#endif 656#endif
@@ -662,13 +684,36 @@ main (int argc, char *argv[])
662 NULL); 684 NULL);
663 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); 685 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
664 686
687 machine_parsable = GNUNET_NO;
665 peers = NUM_PEERS; 688 peers = NUM_PEERS;
666 if (argc == 2) 689 config_file = "test_transport_ats_1addr.conf";
690
691 int c = 0;
692 if (argc >= 2)
667 { 693 {
668 peers = atoi(argv[1]); 694 for (c=0; c<argc; c++)
669 peers++; 695 {
696 /* set peers */
697 if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
698 {
699 peers = atoi(argv[c+1]);
700 peers++;
701 }
702 /* set machine parsable */
703 if (strcmp(argv[c], "-m") == 0)
704 {
705 machine_parsable = GNUNET_YES;
706 }
707 /* set config file */
708 if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
709 {
710 config_file = argv[c+1];
711 }
712 }
670 } 713 }
671 714
715
716
672 ret = check (); 717 ret = check ();
673 /** 718 /**
674 * Still need to remove the base testing directory here, 719 * Still need to remove the base testing directory here,