aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-12 17:49:44 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-12 17:49:44 +0200
commitee2e28090ba508ab3db2040c87383c990efee79b (patch)
treefc8835e1a346358111ee6ab12850dd2ad18a97f4 /src
parent620bdac536dff4b17317d9d20b8a6840836d6490 (diff)
downloadgnunet-ee2e28090ba508ab3db2040c87383c990efee79b.tar.gz
gnunet-ee2e28090ba508ab3db2040c87383c990efee79b.zip
add logic to compute statistics from benchmark
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-gns-benchmark.c116
-rw-r--r--src/namestore/gnunet-zoneimport.c4
2 files changed, 106 insertions, 14 deletions
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c
index f1efaac09..7f47fd9ca 100644
--- a/src/gns/gnunet-gns-benchmark.c
+++ b/src/gns/gnunet-gns-benchmark.c
@@ -286,7 +286,29 @@ process_queue (void *cls)
286 286
287 287
288/** 288/**
289 * Clean up and terminate the process. 289 * Compare two requests by latency for qsort().
290 *
291 * @param c1 pointer to `struct Request *`
292 * @param c2 pointer to `struct Request *`
293 * @return -1 if c1<c2, 1 if c1>c2, 0 if c1==c2.
294 */
295static int
296compare_req (const void *c1,
297 const void *c2)
298{
299 const struct Request *r1 = *(void **) c1;
300 const struct Request *r2 = *(void **) c2;
301
302 if (r1->latency.rel_value_us < r2->latency.rel_value_us)
303 return -1;
304 if (r1->latency.rel_value_us > r2->latency.rel_value_us)
305 return 1;
306 return 0;
307}
308
309
310/**
311 * Output statistics, then clean up and terminate the process.
290 * 312 *
291 * @param cls NULL 313 * @param cls NULL
292 */ 314 */
@@ -294,9 +316,68 @@ static void
294do_shutdown (void *cls) 316do_shutdown (void *cls)
295{ 317{
296 struct Request *req; 318 struct Request *req;
319 struct Request **ra[RC_MAX];
320 unsigned int rp[RC_MAX];
297 321
298 (void) cls; 322 (void) cls;
299 /* FIXME: calculate statistics */ 323 for (enum RequestCategory rc = 0;rc < RC_MAX;rc++)
324 {
325 ra[rc] = GNUNET_new_array (replies[rc],
326 struct Request *);
327 rp[rc] = 0;
328 }
329 for (req = succ_head;NULL != req; req = req->next)
330 {
331 GNUNET_assert (rp[req->cat] < replies[req->cat]);
332 ra[req->cat][rp[req->cat]++] = req;
333 }
334 for (enum RequestCategory rc = 0;rc < RC_MAX;rc++)
335 {
336 unsigned int off;
337
338 if (0 == rp[rc])
339 continue;
340 qsort (ra[rc],
341 rp[rc],
342 sizeof (struct Request *),
343 &compare_req);
344 fprintf (stdout,
345 "Category %u\n",
346 rc);
347 latency_sum[off] = GNUNET_TIME_relative_divide (latency_sum[off],
348 replies[rc]);
349 fprintf (stdout,
350 "\taverage: %s\n",
351 GNUNET_STRINGS_relative_time_to_string (latency_sum[off],
352 GNUNET_YES));
353 off = rp[rc] * 50 / 100;
354 fprintf (stdout,
355 "\tmedian(50): %s\n",
356 GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency,
357 GNUNET_YES));
358 off = rp[rc] * 75 / 100;
359 fprintf (stdout,
360 "\tquantile(75): %s\n",
361 GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency,
362 GNUNET_YES));
363 off = rp[rc] * 90 / 100;
364 fprintf (stdout,
365 "\tquantile(90): %s\n",
366 GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency,
367 GNUNET_YES));
368 off = rp[rc] * 99 / 100;
369 fprintf (stdout,
370 "\tquantile(99): %s\n",
371 GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency,
372 GNUNET_YES));
373 fprintf (stdout,
374 "\tlookups: %u replies: %u failures: %u\n",
375 lookups[rc],
376 replies[rc],
377 failures[rc]);
378 GNUNET_free (ra[rc]);
379 }
380
300 if (NULL != gns) 381 if (NULL != gns)
301 { 382 {
302 GNUNET_GNS_disconnect (gns); 383 GNUNET_GNS_disconnect (gns);
@@ -377,33 +458,46 @@ process_stdin (void *cls)
377{ 458{
378 static struct GNUNET_TIME_Absolute last; 459 static struct GNUNET_TIME_Absolute last;
379 static uint64_t idot; 460 static uint64_t idot;
380 char hn[270]; 461 unsigned int cat;
462 char hn[256];
463 char in[270];
381 464
382 (void) cls; 465 (void) cls;
383 t = NULL; 466 t = NULL;
384 while (NULL != 467 while (NULL !=
385 fgets (hn, 468 fgets (in,
386 sizeof (hn), 469 sizeof (in),
387 stdin)) 470 stdin))
388 { 471 {
389 if (strlen(hn) > 0) 472 if (strlen(in) > 0)
390 hn[strlen(hn)-1] = '\0'; /* eat newline */ 473 hn[strlen(in)-1] = '\0'; /* eat newline */
474 if ( (2 != sscanf (in,
475 "%u %255s",
476 &cat,
477 hn)) ||
478 (cat >= RC_MAX) )
479 {
480 fprintf (stderr,
481 "Malformed input line `%s', skipping\n",
482 in);
483 continue;
484 }
391 if (0 == idot) 485 if (0 == idot)
392 last = GNUNET_TIME_absolute_get (); 486 last = GNUNET_TIME_absolute_get ();
393 idot++; 487 idot++;
394 if (0 == idot % 10000) 488 if (0 == idot % 100000)
395 { 489 {
396 struct GNUNET_TIME_Relative delta; 490 struct GNUNET_TIME_Relative delta;
397 491
398 delta = GNUNET_TIME_absolute_get_duration (last); 492 delta = GNUNET_TIME_absolute_get_duration (last);
399 last = GNUNET_TIME_absolute_get (); 493 last = GNUNET_TIME_absolute_get ();
400 fprintf (stderr, 494 fprintf (stderr,
401 "Imported 10000 records in %s\n", 495 "Read 10000 domain names in %s\n",
402 GNUNET_STRINGS_relative_time_to_string (delta, 496 GNUNET_STRINGS_relative_time_to_string (delta,
403 GNUNET_YES)); 497 GNUNET_YES));
404 } 498 }
405 queue (hn, 499 queue (hn,
406 RC_SHARED); // FIXME: parse input line! 500 (enum RequestCategory) cat);
407 } 501 }
408 fprintf (stderr, 502 fprintf (stderr,
409 "Done reading %llu domain names\n", 503 "Done reading %llu domain names\n",
@@ -487,8 +581,6 @@ main (int argc,
487 NULL)) 581 NULL))
488 ret = 1; 582 ret = 1;
489 GNUNET_free ((void*) argv); 583 GNUNET_free ((void*) argv);
490 fprintf (stderr,
491 "Statistics here\n");
492 return ret; 584 return ret;
493} 585}
494 586
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index f9e3ad99e..97133766e 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -1835,14 +1835,14 @@ process_stdin (void *cls)
1835 if (0 == idot) 1835 if (0 == idot)
1836 last = GNUNET_TIME_absolute_get (); 1836 last = GNUNET_TIME_absolute_get ();
1837 idot++; 1837 idot++;
1838 if (0 == idot % 10000) 1838 if (0 == idot % 100000)
1839 { 1839 {
1840 struct GNUNET_TIME_Relative delta; 1840 struct GNUNET_TIME_Relative delta;
1841 1841
1842 delta = GNUNET_TIME_absolute_get_duration (last); 1842 delta = GNUNET_TIME_absolute_get_duration (last);
1843 last = GNUNET_TIME_absolute_get (); 1843 last = GNUNET_TIME_absolute_get ();
1844 fprintf (stderr, 1844 fprintf (stderr,
1845 "Imported 10000 records in %s\n", 1845 "Read 10000 domain names in %s\n",
1846 GNUNET_STRINGS_relative_time_to_string (delta, 1846 GNUNET_STRINGS_relative_time_to_string (delta,
1847 GNUNET_YES)); 1847 GNUNET_YES));
1848 GNUNET_STATISTICS_set (stats, 1848 GNUNET_STATISTICS_set (stats,