summaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-profiler.c')
-rw-r--r--src/fs/gnunet-fs-profiler.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c
index 8a71c5a59..d47ca8b29 100644
--- a/src/fs/gnunet-fs-profiler.c
+++ b/src/fs/gnunet-fs-profiler.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file fs/gnunet-fs-profiler.c 22 * @file fs/gnunet-fs-profiler.c
@@ -62,15 +62,15 @@ static struct GNUNET_SCHEDULER_Task * terminate_taskid;
62 * operation has executed successfully. 62 * operation has executed successfully.
63 */ 63 */
64static void 64static void
65shutdown_task (void *cls, 65shutdown_task(void *cls,
66 struct GNUNET_TESTBED_Operation *op, 66 struct GNUNET_TESTBED_Operation *op,
67 const char *emsg) 67 const char *emsg)
68{ 68{
69 if (NULL != emsg) 69 if (NULL != emsg)
70 fprintf (stderr, 70 fprintf(stderr,
71 "Error collecting statistics: %s\n", 71 "Error collecting statistics: %s\n",
72 emsg); 72 emsg);
73 GNUNET_SCHEDULER_shutdown (); 73 GNUNET_SCHEDULER_shutdown();
74} 74}
75 75
76 76
@@ -87,19 +87,19 @@ shutdown_task (void *cls,
87 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 87 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
88 */ 88 */
89static int 89static int
90process_stats (void *cls, 90process_stats(void *cls,
91 const struct GNUNET_TESTBED_Peer *peer, 91 const struct GNUNET_TESTBED_Peer *peer,
92 const char *subsystem, 92 const char *subsystem,
93 const char *name, 93 const char *name,
94 uint64_t value, 94 uint64_t value,
95 int is_persistent) 95 int is_persistent)
96{ 96{
97 fprintf (stdout, 97 fprintf(stdout,
98 "%p-%s: %s = %llu\n", 98 "%p-%s: %s = %llu\n",
99 peer, 99 peer,
100 subsystem, 100 subsystem,
101 name, 101 name,
102 (unsigned long long) value); 102 (unsigned long long)value);
103 return GNUNET_OK; 103 return GNUNET_OK;
104} 104}
105 105
@@ -111,18 +111,18 @@ process_stats (void *cls,
111 * @param cls NULL 111 * @param cls NULL
112 */ 112 */
113static void 113static void
114terminate_task (void *cls) 114terminate_task(void *cls)
115{ 115{
116 if (NULL != terminate_taskid) 116 if (NULL != terminate_taskid)
117 { 117 {
118 GNUNET_SCHEDULER_cancel (terminate_taskid); 118 GNUNET_SCHEDULER_cancel(terminate_taskid);
119 terminate_taskid = NULL; 119 terminate_taskid = NULL;
120 } 120 }
121 GNUNET_TESTBED_get_statistics (0, NULL, 121 GNUNET_TESTBED_get_statistics(0, NULL,
122 NULL, NULL, 122 NULL, NULL,
123 &process_stats, 123 &process_stats,
124 &shutdown_task, 124 &shutdown_task,
125 NULL); 125 NULL);
126} 126}
127 127
128 128
@@ -133,10 +133,10 @@ terminate_task (void *cls)
133 * @param cls NULL 133 * @param cls NULL
134 */ 134 */
135static void 135static void
136timeout_task (void *cls) 136timeout_task(void *cls)
137{ 137{
138 terminate_taskid = NULL; 138 terminate_taskid = NULL;
139 GNUNET_SCHEDULER_shutdown (); 139 GNUNET_SCHEDULER_shutdown();
140} 140}
141 141
142 142
@@ -153,23 +153,23 @@ timeout_task (void *cls)
153 * failed 153 * failed
154 */ 154 */
155static void 155static void
156test_master (void *cls, 156test_master(void *cls,
157 struct GNUNET_TESTBED_RunHandle *h, 157 struct GNUNET_TESTBED_RunHandle *h,
158 unsigned int num_peers, 158 unsigned int num_peers,
159 struct GNUNET_TESTBED_Peer **peers, 159 struct GNUNET_TESTBED_Peer **peers,
160 unsigned int links_succeeded, 160 unsigned int links_succeeded,
161 unsigned int links_failed) 161 unsigned int links_failed)
162{ 162{
163 // const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 163 // const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
164 // FIXME: enable clients to signal 'completion' before timeout; 164 // FIXME: enable clients to signal 'completion' before timeout;
165 // in that case, run the 'terminate_task' "immediately" 165 // in that case, run the 'terminate_task' "immediately"
166 166
167 if (0 != timeout.rel_value_us) 167 if (0 != timeout.rel_value_us)
168 terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout, 168 terminate_taskid = GNUNET_SCHEDULER_add_delayed(timeout,
169 &timeout_task, 169 &timeout_task,
170 NULL); 170 NULL);
171 GNUNET_SCHEDULER_add_shutdown (&terminate_task, 171 GNUNET_SCHEDULER_add_shutdown(&terminate_task,
172 NULL); 172 NULL);
173} 173}
174 174
175 175
@@ -182,14 +182,14 @@ test_master (void *cls,
182 * @param cfg configuration 182 * @param cfg configuration
183 */ 183 */
184static void 184static void
185run (void *cls, char *const *args, const char *cfgfile, 185run(void *cls, char *const *args, const char *cfgfile,
186 const struct GNUNET_CONFIGURATION_Handle *cfg) 186 const struct GNUNET_CONFIGURATION_Handle *cfg)
187{ 187{
188 GNUNET_TESTBED_run (host_filename, 188 GNUNET_TESTBED_run(host_filename,
189 cfg, 189 cfg,
190 num_peers, 190 num_peers,
191 0, NULL, NULL, 191 0, NULL, NULL,
192 &test_master, (void *) cfg); 192 &test_master, (void *)cfg);
193} 193}
194 194
195 195
@@ -201,38 +201,38 @@ run (void *cls, char *const *args, const char *cfgfile,
201 * @return 0 ok, 1 on error 201 * @return 0 ok, 1 on error
202 */ 202 */
203int 203int
204main (int argc, char *const *argv) 204main(int argc, char *const *argv)
205{ 205{
206 struct GNUNET_GETOPT_CommandLineOption options[] = { 206 struct GNUNET_GETOPT_CommandLineOption options[] = {
207 207 GNUNET_GETOPT_option_uint('n',
208 GNUNET_GETOPT_option_uint ('n', 208 "num-peers",
209 "num-peers", 209 "COUNT",
210 "COUNT", 210 gettext_noop("run the experiment with COUNT peers"),
211 gettext_noop ("run the experiment with COUNT peers"), 211 &num_peers),
212 &num_peers), 212
213 213 GNUNET_GETOPT_option_string('H',
214 GNUNET_GETOPT_option_string ('H', 214 "hosts",
215 "hosts", 215 "HOSTFILE",
216 "HOSTFILE", 216 gettext_noop("specifies name of a file with the HOSTS the testbed should use"),
217 gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), 217 &host_filename),
218 &host_filename), 218
219 219 GNUNET_GETOPT_option_relative_time('t',
220 GNUNET_GETOPT_option_relative_time ('t', 220 "timeout",
221 "timeout", 221 "DELAY",
222 "DELAY", 222 gettext_noop("automatically terminate experiment after DELAY"),
223 gettext_noop ("automatically terminate experiment after DELAY"), 223 &timeout),
224 &timeout),
225 224
226 GNUNET_GETOPT_OPTION_END 225 GNUNET_GETOPT_OPTION_END
227 }; 226 };
228 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 227
228 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
229 return 2; 229 return 2;
230 230
231 ret = (GNUNET_OK == 231 ret = (GNUNET_OK ==
232 GNUNET_PROGRAM_run (argc, argv, "gnunet-fs-profiler", 232 GNUNET_PROGRAM_run(argc, argv, "gnunet-fs-profiler",
233 gettext_noop ("run a testbed to measure file-sharing performance"), options, &run, 233 gettext_noop("run a testbed to measure file-sharing performance"), options, &run,
234 NULL)) ? ret : 1; 234 NULL)) ? ret : 1;
235 GNUNET_free ((void*) argv); 235 GNUNET_free((void*)argv);
236 return ret; 236 return ret;
237} 237}
238 238