diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-12-08 15:14:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-12-08 15:14:00 +0000 |
commit | 33ead6c4ef534690c738a16f5467f2e4fa1ed9c9 (patch) | |
tree | 8eba75cdbf19abaf95b20bbb9570831e7834e09b /src/fs/gnunet-fs-profiler.c | |
parent | a9c860c0fff4cb75afa7518a9137977b096e8bff (diff) | |
download | gnunet-33ead6c4ef534690c738a16f5467f2e4fa1ed9c9.tar.gz gnunet-33ead6c4ef534690c738a16f5467f2e4fa1ed9c9.zip |
-virtually finished fs profiler
Diffstat (limited to 'src/fs/gnunet-fs-profiler.c')
-rw-r--r-- | src/fs/gnunet-fs-profiler.c | 98 |
1 files changed, 94 insertions, 4 deletions
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 | */ |
43 | static unsigned int num_peers; | 43 | static unsigned int num_peers; |
44 | 44 | ||
45 | /** | ||
46 | * After how long do we abort the test? | ||
47 | */ | ||
48 | static struct GNUNET_TIME_Relative timeout; | ||
49 | |||
50 | /** | ||
51 | * Handle to the task run during termination. | ||
52 | */ | ||
53 | static 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 | */ | ||
64 | static void | ||
65 | shutdown_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 | */ | ||
89 | static int | ||
90 | process_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 | */ | ||
114 | static void | ||
115 | terminate_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)) |