[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25327 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25327 - gnunet/src/fs |
Date: |
Sat, 8 Dec 2012 16:14:00 +0100 |
Author: grothoff
Date: 2012-12-08 16:14:00 +0100 (Sat, 08 Dec 2012)
New Revision: 25327
Modified:
gnunet/src/fs/gnunet-daemon-fsprofiler.c
gnunet/src/fs/gnunet-fs-profiler.c
Log:
-virtually finished fs profiler
Modified: gnunet/src/fs/gnunet-daemon-fsprofiler.c
===================================================================
--- gnunet/src/fs/gnunet-daemon-fsprofiler.c 2012-12-08 13:23:41 UTC (rev
25326)
+++ gnunet/src/fs/gnunet-daemon-fsprofiler.c 2012-12-08 15:14:00 UTC (rev
25327)
@@ -24,7 +24,6 @@
* @author Christian Grothoff
*
* TODO:
- * - actually collect performance metrics
* - how to signal driver that we're done?
*/
#include "platform.h"
@@ -387,13 +386,19 @@
p = info->value.publish.cctx;
return p;
case GNUNET_FS_STATUS_PUBLISH_ERROR:
- // FIXME: statistics...
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Publishing failed\n");
+ GNUNET_STATISTICS_update (stats_handle,
+ "# failed publish operations", 1, GNUNET_NO);
p = info->value.publish.cctx;
p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p);
return p;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
- // FIXME: statistics...
p = info->value.publish.cctx;
+ GNUNET_STATISTICS_update (stats_handle,
+ "# publishing time (ms)",
+ (long long) GNUNET_TIME_absolute_get_duration
(p->start_time).rel_value,
+ GNUNET_NO);
p->task = GNUNET_SCHEDULER_add_now (&publish_stop_task, p);
return p;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
@@ -409,14 +414,19 @@
p = info->value.download.cctx;
return p;
case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
- // FIXME: statistics
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Download failed\n");
+ GNUNET_STATISTICS_update (stats_handle,
+ "# failed downloads", 1, GNUNET_NO);
p = info->value.download.cctx;
p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
return p;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
- // FIXME: statistics
p = info->value.download.cctx;
- p->task = GNUNET_SCHEDULER_add_now (&download_stop_task, p);
+ GNUNET_STATISTICS_update (stats_handle,
+ "# download time (ms)",
+ (long long) GNUNET_TIME_absolute_get_duration
(p->start_time).rel_value,
+ GNUNET_NO); p->task = GNUNET_SCHEDULER_add_now
(&download_stop_task, p);
return p;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
p = info->value.download.cctx;
@@ -438,6 +448,11 @@
return NULL; /* not what we want */
if (p->y != GNUNET_FS_uri_chk_get_file_size (uri))
return NULL; /* not what we want */
+ GNUNET_STATISTICS_update (stats_handle,
+ "# search time (ms)",
+ (long long) GNUNET_TIME_absolute_get_duration
(p->start_time).rel_value,
+ GNUNET_NO);
+ p->start_time = GNUNET_TIME_absolute_get ();
p->ctx = GNUNET_FS_download_start (fs_handle, uri,
NULL, NULL, NULL,
0, GNUNET_FS_uri_chk_get_file_size (uri),
@@ -451,7 +466,10 @@
case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
return NULL; /* don't care */
case GNUNET_FS_STATUS_SEARCH_ERROR:
- // FIXME: statistics
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Search failed\n");
+ GNUNET_STATISTICS_update (stats_handle,
+ "# failed searches", 1, GNUNET_NO);
p = info->value.search.cctx;
p->stask = GNUNET_SCHEDULER_add_now (&search_stop_task, p);
return p;
@@ -489,6 +507,7 @@
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
fi = make_file (p->x, p->y, p);
+ p->start_time = GNUNET_TIME_absolute_get ();
p->ctx = GNUNET_FS_publish_start (fs_handle,
fi,
NULL, NULL, NULL,
@@ -513,6 +532,7 @@
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
keywords = make_keywords (p->x);
+ p->start_time = GNUNET_TIME_absolute_get ();
p->sctx = GNUNET_FS_search_start (fs_handle, keywords,
anonymity_level,
GNUNET_FS_SEARCH_OPTION_NONE,
Modified: gnunet/src/fs/gnunet-fs-profiler.c
===================================================================
--- gnunet/src/fs/gnunet-fs-profiler.c 2012-12-08 13:23:41 UTC (rev 25326)
+++ gnunet/src/fs/gnunet-fs-profiler.c 2012-12-08 15:14:00 UTC (rev 25327)
@@ -42,8 +42,88 @@
*/
static unsigned int num_peers;
+/**
+ * After how long do we abort the test?
+ */
+static struct GNUNET_TIME_Relative timeout;
/**
+ * Handle to the task run during termination.
+ */
+static GNUNET_SCHEDULER_TaskIdentifier terminate_taskid;
+
+
+/**
+ * Function called after we've collected the statistics.
+ *
+ * @param cls NULL
+ * @param op the operation that has been finished
+ * @param emsg error message in case the operation has failed; will be NULL if
+ * operation has executed successfully.
+ */
+static void
+shutdown_task (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ const char *emsg)
+{
+ if (NULL != emsg)
+ fprintf (stderr,
+ "Error collecting statistics: %s\n",
+ emsg);
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
+ * Callback function to process statistic values from all peers.
+ * Prints them out.
+ *
+ * @param cls closure
+ * @param peer the peer the statistic belong to
+ * @param subsystem name of subsystem that created the statistic
+ * @param name the name of the datum
+ * @param value the current value
+ * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ */
+static int
+process_stats (void *cls,
+ const struct GNUNET_TESTBED_Peer *peer,
+ const char *subsystem,
+ const char *name,
+ uint64_t value,
+ int is_persistent)
+{
+ fprintf (stdout,
+ "%p-%s: %s = %llu\n",
+ peer,
+ subsystem,
+ name,
+ (unsigned long long) value);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Task run on timeout to terminate. Triggers printing out
+ * all statistics.
+ *
+ * @param cls NULL
+ * @param tc unused
+ */
+static void
+terminate_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ terminate_taskid = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_TESTBED_get_statistics (0, NULL,
+ &process_stats,
+ &shutdown_task,
+ NULL);
+}
+
+
+/**
* The testbed has been started, now begin the experiment.
*
* @param cls configuration handle
@@ -54,8 +134,16 @@
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
// const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ // FIXME: enable clients to signal 'completion' before timeout;
+ // in that case, run the 'terminate_task' "immediately"
- GNUNET_SCHEDULER_shutdown ();
+ if (0 != timeout.rel_value)
+ terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout,
+ &terminate_task, NULL);
+ else
+ terminate_taskid = GNUNET_SCHEDULER_add_delayed
(GNUNET_TIME_UNIT_FOREVER_REL,
+ &terminate_task,
+ NULL);
}
@@ -93,10 +181,12 @@
{'n', "num-peers", "COUNT",
gettext_noop ("run the experiment with COUNT peers"),
1, &GNUNET_GETOPT_set_uint, &num_peers},
- {'t', "testbed", "HOSTFILE",
+ {'H', "hosts", "HOSTFILE",
gettext_noop ("specifies name of a file with the HOSTS the testbed should
use"),
1, &GNUNET_GETOPT_set_string, &host_filename},
-
+ {'t', "timeout", "DELAY",
+ gettext_noop ("automatically terminate experiment after DELAY"),
+ 1, &GNUNET_GETOPT_set_relative_time, &timeout},
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25327 - gnunet/src/fs,
gnunet <=