aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c34
-rw-r--r--src/fs/gnunet-fs-profiler.c98
2 files changed, 121 insertions, 11 deletions
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c
index 49583962d..16a74b8a0 100644
--- a/src/fs/gnunet-daemon-fsprofiler.c
+++ b/src/fs/gnunet-daemon-fsprofiler.c
@@ -24,7 +24,6 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * 25 *
26 * TODO: 26 * TODO:
27 * - actually collect performance metrics
28 * - how to signal driver that we're done? 27 * - how to signal driver that we're done?
29 */ 28 */
30#include "platform.h" 29#include "platform.h"
@@ -387,13 +386,19 @@ progress_cb (void *cls,
387 p = info->value.publish.cctx; 386 p = info->value.publish.cctx;
388 return p; 387 return p;
389 case GNUNET_FS_STATUS_PUBLISH_ERROR: 388 case GNUNET_FS_STATUS_PUBLISH_ERROR:
390 // FIXME: statistics... 389 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
390 "Publishing failed\n");
391 GNUNET_STATISTICS_update (stats_handle,
392 "# failed publish operations", 1, GNUNET_NO);
391 p = info->value.publish.cctx; 393 p = info->value.publish.cctx;
392 p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p); 394 p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p);
393 return p; 395 return p;
394 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 396 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
395 // FIXME: statistics...
396 p = info->value.publish.cctx; 397 p = info->value.publish.cctx;
398 GNUNET_STATISTICS_update (stats_handle,
399 "# publishing time (ms)",
400 (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
401 GNUNET_NO);
397 p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p); 402 p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p);
398 return p; 403 return p;
399 case GNUNET_FS_STATUS_PUBLISH_STOPPED: 404 case GNUNET_FS_STATUS_PUBLISH_STOPPED:
@@ -409,14 +414,19 @@ progress_cb (void *cls,
409 p = info->value.download.cctx; 414 p = info->value.download.cctx;
410 return p; 415 return p;
411 case GNUNET_FS_STATUS_DOWNLOAD_ERROR: 416 case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
412 // FIXME: statistics 417 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
418 "Download failed\n");
419 GNUNET_STATISTICS_update (stats_handle,
420 "# failed downloads", 1, GNUNET_NO);
413 p = info->value.download.cctx; 421 p = info->value.download.cctx;
414 p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p); 422 p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
415 return p; 423 return p;
416 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 424 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
417 // FIXME: statistics
418 p = info->value.download.cctx; 425 p = info->value.download.cctx;
419 p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p); 426 GNUNET_STATISTICS_update (stats_handle,
427 "# download time (ms)",
428 (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
429 GNUNET_NO); p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
420 return p; 430 return p;
421 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 431 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
422 p = info->value.download.cctx; 432 p = info->value.download.cctx;
@@ -438,6 +448,11 @@ progress_cb (void *cls,
438 return NULL; /* not what we want */ 448 return NULL; /* not what we want */
439 if (p->y != GNUNET_FS_uri_chk_get_file_size (uri)) 449 if (p->y != GNUNET_FS_uri_chk_get_file_size (uri))
440 return NULL; /* not what we want */ 450 return NULL; /* not what we want */
451 GNUNET_STATISTICS_update (stats_handle,
452 "# search time (ms)",
453 (long long) GNUNET_TIME_absolute_get_duration (p->start_time).rel_value,
454 GNUNET_NO);
455 p->start_time = GNUNET_TIME_absolute_get ();
441 p->ctx = GNUNET_FS_download_start (fs_handle, uri, 456 p->ctx = GNUNET_FS_download_start (fs_handle, uri,
442 NULL, NULL, NULL, 457 NULL, NULL, NULL,
443 0, GNUNET_FS_uri_chk_get_file_size (uri), 458 0, GNUNET_FS_uri_chk_get_file_size (uri),
@@ -451,7 +466,10 @@ progress_cb (void *cls,
451 case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED: 466 case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
452 return NULL; /* don't care */ 467 return NULL; /* don't care */
453 case GNUNET_FS_STATUS_SEARCH_ERROR: 468 case GNUNET_FS_STATUS_SEARCH_ERROR:
454 // FIXME: statistics 469 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
470 "Search failed\n");
471 GNUNET_STATISTICS_update (stats_handle,
472 "# failed searches", 1, GNUNET_NO);
455 p = info->value.search.cctx; 473 p = info->value.search.cctx;
456 p->stask = GNUNET_SCHEDULER_add_now (&search_stop_task, p); 474 p->stask = GNUNET_SCHEDULER_add_now (&search_stop_task, p);
457 return p; 475 return p;
@@ -489,6 +507,7 @@ start_publish (void *cls,
489 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 507 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
490 return; 508 return;
491 fi = make_file (p->x, p->y, p); 509 fi = make_file (p->x, p->y, p);
510 p->start_time = GNUNET_TIME_absolute_get ();
492 p->ctx = GNUNET_FS_publish_start (fs_handle, 511 p->ctx = GNUNET_FS_publish_start (fs_handle,
493 fi, 512 fi,
494 NULL, NULL, NULL, 513 NULL, NULL, NULL,
@@ -513,6 +532,7 @@ start_download (void *cls,
513 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 532 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
514 return; 533 return;
515 keywords = make_keywords (p->x); 534 keywords = make_keywords (p->x);
535 p->start_time = GNUNET_TIME_absolute_get ();
516 p->sctx = GNUNET_FS_search_start (fs_handle, keywords, 536 p->sctx = GNUNET_FS_search_start (fs_handle, keywords,
517 anonymity_level, 537 anonymity_level,
518 GNUNET_FS_SEARCH_OPTION_NONE, 538 GNUNET_FS_SEARCH_OPTION_NONE,
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c
index a7ef7786d..4d4d34051 100644
--- a/src/fs/gnunet-fs-profiler.c
+++ b/src/fs/gnunet-fs-profiler.c
@@ -42,6 +42,86 @@ static char *host_filename;
42 */ 42 */
43static unsigned int num_peers; 43static unsigned int num_peers;
44 44
45/**
46 * After how long do we abort the test?
47 */
48static struct GNUNET_TIME_Relative timeout;
49
50/**
51 * Handle to the task run during termination.
52 */
53static GNUNET_SCHEDULER_TaskIdentifier terminate_taskid;
54
55
56/**
57 * Function called after we've collected the statistics.
58 *
59 * @param cls NULL
60 * @param op the operation that has been finished
61 * @param emsg error message in case the operation has failed; will be NULL if
62 * operation has executed successfully.
63 */
64static void
65shutdown_task (void *cls,
66 struct GNUNET_TESTBED_Operation *op,
67 const char *emsg)
68{
69 if (NULL != emsg)
70 fprintf (stderr,
71 "Error collecting statistics: %s\n",
72 emsg);
73 GNUNET_SCHEDULER_shutdown ();
74}
75
76
77/**
78 * Callback function to process statistic values from all peers.
79 * Prints them out.
80 *
81 * @param cls closure
82 * @param peer the peer the statistic belong to
83 * @param subsystem name of subsystem that created the statistic
84 * @param name the name of the datum
85 * @param value the current value
86 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
87 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
88 */
89static int
90process_stats (void *cls,
91 const struct GNUNET_TESTBED_Peer *peer,
92 const char *subsystem,
93 const char *name,
94 uint64_t value,
95 int is_persistent)
96{
97 fprintf (stdout,
98 "%p-%s: %s = %llu\n",
99 peer,
100 subsystem,
101 name,
102 (unsigned long long) value);
103 return GNUNET_OK;
104}
105
106
107/**
108 * Task run on timeout to terminate. Triggers printing out
109 * all statistics.
110 *
111 * @param cls NULL
112 * @param tc unused
113 */
114static void
115terminate_task (void *cls,
116 const struct GNUNET_SCHEDULER_TaskContext *tc)
117{
118 terminate_taskid = GNUNET_SCHEDULER_NO_TASK;
119 GNUNET_TESTBED_get_statistics (0, NULL,
120 &process_stats,
121 &shutdown_task,
122 NULL);
123}
124
45 125
46/** 126/**
47 * The testbed has been started, now begin the experiment. 127 * The testbed has been started, now begin the experiment.
@@ -54,8 +134,16 @@ master_task (void *cls,
54 const struct GNUNET_SCHEDULER_TaskContext *tc) 134 const struct GNUNET_SCHEDULER_TaskContext *tc)
55{ 135{
56 // const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 136 // const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
57 137 // FIXME: enable clients to signal 'completion' before timeout;
58 GNUNET_SCHEDULER_shutdown (); 138 // in that case, run the 'terminate_task' "immediately"
139
140 if (0 != timeout.rel_value)
141 terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout,
142 &terminate_task, NULL);
143 else
144 terminate_taskid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
145 &terminate_task,
146 NULL);
59} 147}
60 148
61 149
@@ -93,10 +181,12 @@ main (int argc, char *const *argv)
93 {'n', "num-peers", "COUNT", 181 {'n', "num-peers", "COUNT",
94 gettext_noop ("run the experiment with COUNT peers"), 182 gettext_noop ("run the experiment with COUNT peers"),
95 1, &GNUNET_GETOPT_set_uint, &num_peers}, 183 1, &GNUNET_GETOPT_set_uint, &num_peers},
96 {'t', "testbed", "HOSTFILE", 184 {'H', "hosts", "HOSTFILE",
97 gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), 185 gettext_noop ("specifies name of a file with the HOSTS the testbed should use"),
98 1, &GNUNET_GETOPT_set_string, &host_filename}, 186 1, &GNUNET_GETOPT_set_string, &host_filename},
99 187 {'t', "timeout", "DELAY",
188 gettext_noop ("automatically terminate experiment after DELAY"),
189 1, &GNUNET_GETOPT_set_relative_time, &timeout},
100 GNUNET_GETOPT_OPTION_END 190 GNUNET_GETOPT_OPTION_END
101 }; 191 };
102 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 192 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))