diff options
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r-- | src/ats-tests/perf_ats.c | 570 |
1 files changed, 292 insertions, 278 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index c31e8a1c4..470c687fc 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -31,15 +31,20 @@ | |||
31 | #include "ats-testing.h" | 31 | #include "ats-testing.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) | 34 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply ( \ |
35 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
35 | #define TEST_ATS_PREFRENCE_START 1.0 | 36 | #define TEST_ATS_PREFRENCE_START 1.0 |
36 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | 37 | #define TEST_ATS_PREFRENCE_DELTA 1.0 |
37 | 38 | ||
38 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) | 39 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply ( \ |
40 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
39 | 41 | ||
40 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120) | 42 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ |
41 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) | 43 | 120) |
42 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500) | 44 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply ( \ |
45 | GNUNET_TIME_UNIT_SECONDS, 10) | ||
46 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
47 | GNUNET_TIME_UNIT_MILLISECONDS, 500) | ||
43 | #define TESTNAME_PREFIX "perf_ats_" | 48 | #define TESTNAME_PREFIX "perf_ats_" |
44 | #define DEFAULT_SLAVES_NUM 2 | 49 | #define DEFAULT_SLAVES_NUM 2 |
45 | #define DEFAULT_MASTERS_NUM 1 | 50 | #define DEFAULT_MASTERS_NUM 1 |
@@ -123,7 +128,7 @@ static struct LoggingHandle *l; | |||
123 | 128 | ||
124 | 129 | ||
125 | static void | 130 | static void |
126 | evaluate() | 131 | evaluate () |
127 | { | 132 | { |
128 | int c_m; | 133 | int c_m; |
129 | int c_s; | 134 | int c_s; |
@@ -139,48 +144,49 @@ evaluate() | |||
139 | 144 | ||
140 | duration = 1 + (perf_duration.rel_value_us / (1000 * 1000)); | 145 | duration = 1 + (perf_duration.rel_value_us / (1000 * 1000)); |
141 | for (c_m = 0; c_m < num_masters; c_m++) | 146 | for (c_m = 0; c_m < num_masters; c_m++) |
147 | { | ||
148 | mp = &mps[c_m]; | ||
149 | fprintf (stderr, | ||
150 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n", | ||
151 | mp->no, mp->total_bytes_sent / 1024, duration, | ||
152 | (mp->total_bytes_sent / 1024) / duration, | ||
153 | mp->total_bytes_received / 1024, duration, | ||
154 | (mp->total_bytes_received / 1024) / duration); | ||
155 | |||
156 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
142 | { | 157 | { |
143 | mp = &mps[c_m]; | 158 | p = &mp->partners[c_s]; |
144 | fprintf(stderr, | 159 | kb_sent_sec = 0; |
145 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n", | 160 | kb_recv_sec = 0; |
146 | mp->no, mp->total_bytes_sent / 1024, duration, | 161 | kb_sent_percent = 0.0; |
147 | (mp->total_bytes_sent / 1024) / duration, | 162 | kb_recv_percent = 0.0; |
148 | mp->total_bytes_received / 1024, duration, | 163 | rtt = 0; |
149 | (mp->total_bytes_received / 1024) / duration); | 164 | |
150 | 165 | if (duration > 0) | |
151 | for (c_s = 0; c_s < num_slaves; c_s++) | 166 | { |
152 | { | 167 | kb_sent_sec = (p->bytes_sent / 1024) / duration; |
153 | p = &mp->partners[c_s]; | 168 | kb_recv_sec = (p->bytes_received / 1024) / duration; |
154 | kb_sent_sec = 0; | 169 | } |
155 | kb_recv_sec = 0; | 170 | |
156 | kb_sent_percent = 0.0; | 171 | if (mp->total_bytes_sent > 0) |
157 | kb_recv_percent = 0.0; | 172 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; |
158 | rtt = 0; | 173 | if (mp->total_bytes_received > 0) |
159 | 174 | kb_recv_percent = ((double) p->bytes_received * 100) | |
160 | if (duration > 0) | 175 | / mp->total_bytes_received; |
161 | { | 176 | if (1000 * p->messages_sent > 0) |
162 | kb_sent_sec = (p->bytes_sent / 1024) / duration; | 177 | rtt = p->total_app_rtt / (1000 * p->messages_sent); |
163 | kb_recv_sec = (p->bytes_received / 1024) / duration; | 178 | fprintf (stderr, |
164 | } | 179 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", |
165 | 180 | (mp->pref_partner == p->dest) ? '*' : ' ', | |
166 | if (mp->total_bytes_sent > 0) | 181 | mp->no, p->dest->no, |
167 | kb_sent_percent = ((double)p->bytes_sent * 100) / mp->total_bytes_sent; | 182 | kb_sent_sec, kb_sent_percent, |
168 | if (mp->total_bytes_received > 0) | 183 | kb_recv_sec, kb_recv_percent); |
169 | kb_recv_percent = ((double)p->bytes_received * 100) / mp->total_bytes_received; | 184 | fprintf (stderr, |
170 | if (1000 * p->messages_sent > 0) | 185 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", |
171 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | 186 | (mp->pref_partner == p->dest) ? '*' : ' ', |
172 | fprintf(stderr, | 187 | mp->no, p->dest->no, rtt); |
173 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | ||
174 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
175 | mp->no, p->dest->no, | ||
176 | kb_sent_sec, kb_sent_percent, | ||
177 | kb_recv_sec, kb_recv_percent); | ||
178 | fprintf(stderr, | ||
179 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | ||
180 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
181 | mp->no, p->dest->no, rtt); | ||
182 | } | ||
183 | } | 188 | } |
189 | } | ||
184 | } | 190 | } |
185 | 191 | ||
186 | 192 | ||
@@ -190,24 +196,24 @@ evaluate() | |||
190 | * @param cls NULL | 196 | * @param cls NULL |
191 | */ | 197 | */ |
192 | static void | 198 | static void |
193 | do_shutdown(void *cls) | 199 | do_shutdown (void *cls) |
194 | { | 200 | { |
195 | if (GNUNET_YES == logging) | 201 | if (GNUNET_YES == logging) |
196 | GNUNET_ATS_TEST_logging_clean_up(l); | 202 | GNUNET_ATS_TEST_logging_clean_up (l); |
197 | if (NULL != timeout_task) | 203 | if (NULL != timeout_task) |
198 | { | 204 | { |
199 | GNUNET_SCHEDULER_cancel(timeout_task); | 205 | GNUNET_SCHEDULER_cancel (timeout_task); |
200 | timeout_task = NULL; | 206 | timeout_task = NULL; |
201 | } | 207 | } |
202 | if (NULL != progress_task) | 208 | if (NULL != progress_task) |
203 | { | 209 | { |
204 | fprintf(stderr, "0\n"); | 210 | fprintf (stderr, "0\n"); |
205 | GNUNET_SCHEDULER_cancel(progress_task); | 211 | GNUNET_SCHEDULER_cancel (progress_task); |
206 | progress_task = NULL; | 212 | progress_task = NULL; |
207 | } | 213 | } |
208 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
209 | "Benchmarking done\n"); | 215 | "Benchmarking done\n"); |
210 | GNUNET_ATS_TEST_shutdown_topology(); | 216 | GNUNET_ATS_TEST_shutdown_topology (); |
211 | } | 217 | } |
212 | 218 | ||
213 | 219 | ||
@@ -217,163 +223,166 @@ do_shutdown(void *cls) | |||
217 | * @param cls NULL | 223 | * @param cls NULL |
218 | */ | 224 | */ |
219 | static void | 225 | static void |
220 | do_timeout(void *cls) | 226 | do_timeout (void *cls) |
221 | { | 227 | { |
222 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 228 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
223 | "Terminating with timeout\n"); | 229 | "Terminating with timeout\n"); |
224 | timeout_task = NULL; | 230 | timeout_task = NULL; |
225 | evaluate(); | 231 | evaluate (); |
226 | GNUNET_SCHEDULER_shutdown(); | 232 | GNUNET_SCHEDULER_shutdown (); |
227 | } | 233 | } |
228 | 234 | ||
229 | 235 | ||
230 | static void | 236 | static void |
231 | print_progress(void *cls) | 237 | print_progress (void *cls) |
232 | { | 238 | { |
233 | static int calls; | 239 | static int calls; |
234 | 240 | ||
235 | progress_task = NULL; | 241 | progress_task = NULL; |
236 | fprintf(stderr, | 242 | fprintf (stderr, |
237 | "%llu..", | 243 | "%llu..", |
238 | (long long unsigned)perf_duration.rel_value_us / (1000 * 1000) - calls); | 244 | (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) |
245 | - calls); | ||
239 | calls++; | 246 | calls++; |
240 | 247 | ||
241 | progress_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, | 248 | progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
242 | &print_progress, | 249 | &print_progress, |
243 | NULL); | 250 | NULL); |
244 | } | 251 | } |
245 | 252 | ||
246 | 253 | ||
247 | static void | 254 | static void |
248 | ats_pref_task(void *cls) | 255 | ats_pref_task (void *cls) |
249 | { | 256 | { |
250 | struct BenchmarkPeer *me = cls; | 257 | struct BenchmarkPeer *me = cls; |
251 | 258 | ||
252 | me->ats_task = NULL; | 259 | me->ats_task = NULL; |
253 | 260 | ||
254 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, " Master [%u] set preference for slave [%u] to %f\n", | 261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
255 | me->no, me->pref_partner->no, me->pref_value); | 262 | " Master [%u] set preference for slave [%u] to %f\n", |
256 | GNUNET_ATS_performance_change_preference(me->ats_perf_handle, | 263 | me->no, me->pref_partner->no, me->pref_value); |
257 | &me->pref_partner->id, | 264 | GNUNET_ATS_performance_change_preference (me->ats_perf_handle, |
258 | pref_val, me->pref_value, GNUNET_ATS_PREFERENCE_END); | 265 | &me->pref_partner->id, |
266 | pref_val, me->pref_value, | ||
267 | GNUNET_ATS_PREFERENCE_END); | ||
259 | me->pref_value += TEST_ATS_PREFRENCE_DELTA; | 268 | me->pref_value += TEST_ATS_PREFRENCE_DELTA; |
260 | me->ats_task = GNUNET_SCHEDULER_add_delayed(TEST_ATS_PREFRENCE_FREQUENCY, | 269 | me->ats_task = GNUNET_SCHEDULER_add_delayed (TEST_ATS_PREFRENCE_FREQUENCY, |
261 | &ats_pref_task, cls); | 270 | &ats_pref_task, cls); |
262 | } | 271 | } |
263 | 272 | ||
264 | 273 | ||
265 | static void | 274 | static void |
266 | start_benchmark(void *cls) | 275 | start_benchmark (void *cls) |
267 | { | 276 | { |
268 | int c_m; | 277 | int c_m; |
269 | int c_s; | 278 | int c_s; |
270 | 279 | ||
271 | progress_task = GNUNET_SCHEDULER_add_now(&print_progress, | 280 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, |
272 | NULL); | 281 | NULL); |
273 | 282 | ||
274 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 283 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
275 | "Topology connected, start benchmarking...\n"); | 284 | "Topology connected, start benchmarking...\n"); |
276 | 285 | ||
277 | /* Start sending test messages */ | 286 | /* Start sending test messages */ |
278 | for (c_m = 0; c_m < num_masters; c_m++) | 287 | for (c_m = 0; c_m < num_masters; c_m++) |
288 | { | ||
289 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
279 | { | 290 | { |
280 | for (c_s = 0; c_s < num_slaves; c_s++) | 291 | GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m], |
281 | { | 292 | &mps[c_m].partners[c_s], |
282 | GNUNET_ATS_TEST_generate_traffic_start(&mps[c_m], | 293 | GNUNET_ATS_TEST_TG_LINEAR, |
283 | &mps[c_m].partners[c_s], | 294 | UINT32_MAX, |
284 | GNUNET_ATS_TEST_TG_LINEAR, | 295 | UINT32_MAX, |
285 | UINT32_MAX, | 296 | GNUNET_TIME_UNIT_MINUTES, |
286 | UINT32_MAX, | 297 | GNUNET_TIME_UNIT_FOREVER_REL); |
287 | GNUNET_TIME_UNIT_MINUTES, | ||
288 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
289 | } | ||
290 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
291 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now(&ats_pref_task, | ||
292 | &mps[c_m]); | ||
293 | } | 298 | } |
299 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
300 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, | ||
301 | &mps[c_m]); | ||
302 | } | ||
294 | 303 | ||
295 | if (GNUNET_YES == logging) | 304 | if (GNUNET_YES == logging) |
296 | l = GNUNET_ATS_TEST_logging_start(log_frequency, | 305 | l = GNUNET_ATS_TEST_logging_start (log_frequency, |
297 | testname, mps, | 306 | testname, mps, |
298 | num_masters, num_slaves, | 307 | num_masters, num_slaves, |
299 | GNUNET_NO); | 308 | GNUNET_NO); |
300 | } | 309 | } |
301 | 310 | ||
302 | 311 | ||
303 | static void | 312 | static void |
304 | do_benchmark(void *cls, | 313 | do_benchmark (void *cls, |
305 | struct BenchmarkPeer *masters, | 314 | struct BenchmarkPeer *masters, |
306 | struct BenchmarkPeer *slaves) | 315 | struct BenchmarkPeer *slaves) |
307 | { | 316 | { |
308 | mps = masters; | 317 | mps = masters; |
309 | sps = slaves; | 318 | sps = slaves; |
310 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, | 319 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
311 | NULL); | 320 | NULL); |
312 | timeout_task = GNUNET_SCHEDULER_add_delayed(perf_duration, | 321 | timeout_task = GNUNET_SCHEDULER_add_delayed (perf_duration, |
313 | &do_timeout, | 322 | &do_timeout, |
314 | NULL); | 323 | NULL); |
315 | progress_task = GNUNET_SCHEDULER_add_now(&start_benchmark, | 324 | progress_task = GNUNET_SCHEDULER_add_now (&start_benchmark, |
316 | NULL); | 325 | NULL); |
317 | } | 326 | } |
318 | 327 | ||
319 | 328 | ||
320 | static struct BenchmarkPartner * | 329 | static struct BenchmarkPartner * |
321 | find_partner(struct BenchmarkPeer *me, | 330 | find_partner (struct BenchmarkPeer *me, |
322 | const struct GNUNET_PeerIdentity *peer) | 331 | const struct GNUNET_PeerIdentity *peer) |
323 | { | 332 | { |
324 | int c_m; | 333 | int c_m; |
325 | 334 | ||
326 | GNUNET_assert(NULL != me); | 335 | GNUNET_assert (NULL != me); |
327 | GNUNET_assert(NULL != peer); | 336 | GNUNET_assert (NULL != peer); |
328 | 337 | ||
329 | for (c_m = 0; c_m < me->num_partners; c_m++) | 338 | for (c_m = 0; c_m < me->num_partners; c_m++) |
339 | { | ||
340 | /* Find a partner with other as destination */ | ||
341 | if (0 == GNUNET_memcmp (peer, &me->partners[c_m].dest->id)) | ||
330 | { | 342 | { |
331 | /* Find a partner with other as destination */ | 343 | return &me->partners[c_m]; |
332 | if (0 == GNUNET_memcmp(peer, &me->partners[c_m].dest->id)) | ||
333 | { | ||
334 | return &me->partners[c_m]; | ||
335 | } | ||
336 | } | 344 | } |
345 | } | ||
337 | return NULL; | 346 | return NULL; |
338 | } | 347 | } |
339 | 348 | ||
340 | 349 | ||
341 | static void | 350 | static void |
342 | log_request_cb(void *cls, | 351 | log_request_cb (void *cls, |
343 | const struct GNUNET_HELLO_Address *address, | 352 | const struct GNUNET_HELLO_Address *address, |
344 | int address_active, | 353 | int address_active, |
345 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 354 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
346 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 355 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
347 | const struct GNUNET_ATS_Properties *ats) | 356 | const struct GNUNET_ATS_Properties *ats) |
348 | { | 357 | { |
349 | struct BenchmarkPeer *me = cls; | 358 | struct BenchmarkPeer *me = cls; |
350 | struct BenchmarkPartner *p; | 359 | struct BenchmarkPartner *p; |
351 | char *peer_id; | 360 | char *peer_id; |
352 | 361 | ||
353 | p = find_partner(me, &address->peer); | 362 | p = find_partner (me, &address->peer); |
354 | if (NULL == p) | 363 | if (NULL == p) |
355 | { | 364 | { |
356 | /* This is not one of my partners | 365 | /* This is not one of my partners |
357 | * Will happen since the peers will connect to each other due to gossiping | 366 | * Will happen since the peers will connect to each other due to gossiping |
358 | */ | 367 | */ |
359 | return; | 368 | return; |
360 | } | 369 | } |
361 | peer_id = GNUNET_strdup(GNUNET_i2s(&me->id)); | 370 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); |
362 | 371 | ||
363 | if ((p->bandwidth_in != ntohl(bandwidth_in.value__)) || | 372 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || |
364 | (p->bandwidth_out != ntohl(bandwidth_out.value__))) | 373 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) |
365 | p->bandwidth_in = ntohl(bandwidth_in.value__); | 374 | p->bandwidth_in = ntohl (bandwidth_in.value__); |
366 | p->bandwidth_out = ntohl(bandwidth_out.value__); | 375 | p->bandwidth_out = ntohl (bandwidth_out.value__); |
367 | 376 | ||
368 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
369 | "%s [%u] received ATS information for peers `%s'\n", | 378 | "%s [%u] received ATS information for peers `%s'\n", |
370 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | 379 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", |
371 | p->me->no, | 380 | p->me->no, |
372 | GNUNET_i2s(&p->dest->id)); | 381 | GNUNET_i2s (&p->dest->id)); |
373 | 382 | ||
374 | GNUNET_free(peer_id); | 383 | GNUNET_free (peer_id); |
375 | if (NULL != l) | 384 | if (NULL != l) |
376 | GNUNET_ATS_TEST_logging_now(l); | 385 | GNUNET_ATS_TEST_logging_now (l); |
377 | } | 386 | } |
378 | 387 | ||
379 | 388 | ||
@@ -381,7 +390,7 @@ log_request_cb(void *cls, | |||
381 | * Start the performance test case | 390 | * Start the performance test case |
382 | */ | 391 | */ |
383 | int | 392 | int |
384 | main(int argc, char *argv[]) | 393 | main (int argc, char *argv[]) |
385 | { | 394 | { |
386 | char *tmp; | 395 | char *tmp; |
387 | char *tmp_sep; | 396 | char *tmp_sep; |
@@ -398,187 +407,192 @@ main(int argc, char *argv[]) | |||
398 | * perf_ats_<solver>_<transport>_<preference>[.exe]*/ | 407 | * perf_ats_<solver>_<transport>_<preference>[.exe]*/ |
399 | 408 | ||
400 | /* Find test prefix, store in temp */ | 409 | /* Find test prefix, store in temp */ |
401 | tmp = strstr(argv[0], TESTNAME_PREFIX); | 410 | tmp = strstr (argv[0], TESTNAME_PREFIX); |
402 | if (NULL == tmp) | 411 | if (NULL == tmp) |
403 | { | 412 | { |
404 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); | 413 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); |
405 | return GNUNET_SYSERR; | 414 | return GNUNET_SYSERR; |
406 | } | 415 | } |
407 | 416 | ||
408 | /* Set tmp to end of test name prefix */ | 417 | /* Set tmp to end of test name prefix */ |
409 | tmp += strlen(TESTNAME_PREFIX); | 418 | tmp += strlen (TESTNAME_PREFIX); |
410 | 419 | ||
411 | /* Determine solver name */ | 420 | /* Determine solver name */ |
412 | solver = GNUNET_strdup(tmp); | 421 | solver = GNUNET_strdup (tmp); |
413 | /* Remove .exe prefix */ | 422 | /* Remove .exe prefix */ |
414 | if (NULL != (dotexe = strstr(solver, ".exe")) && dotexe[4] == '\0') | 423 | if ((NULL != (dotexe = strstr (solver, ".exe")))&&(dotexe[4] == '\0')) |
415 | dotexe[0] = '\0'; | 424 | dotexe[0] = '\0'; |
416 | 425 | ||
417 | /* Determine first '_' after solver */ | 426 | /* Determine first '_' after solver */ |
418 | tmp_sep = strchr(solver, '_'); | 427 | tmp_sep = strchr (solver, '_'); |
419 | if (NULL == tmp_sep) | 428 | if (NULL == tmp_sep) |
420 | { | 429 | { |
421 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); | 430 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); |
422 | GNUNET_free(solver); | 431 | GNUNET_free (solver); |
423 | return GNUNET_SYSERR; | 432 | return GNUNET_SYSERR; |
424 | } | 433 | } |
425 | tmp_sep[0] = '\0'; | 434 | tmp_sep[0] = '\0'; |
426 | comm_name = GNUNET_strdup(&tmp_sep[1]); | 435 | comm_name = GNUNET_strdup (&tmp_sep[1]); |
427 | tmp_sep = strchr(comm_name, '_'); | 436 | tmp_sep = strchr (comm_name, '_'); |
428 | if (NULL == tmp_sep) | 437 | if (NULL == tmp_sep) |
429 | { | 438 | { |
430 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); | 439 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); |
431 | GNUNET_free(solver); | 440 | GNUNET_free (solver); |
432 | return GNUNET_SYSERR; | 441 | return GNUNET_SYSERR; |
433 | } | 442 | } |
434 | tmp_sep[0] = '\0'; | 443 | tmp_sep[0] = '\0'; |
435 | for (c = 0; c <= strlen(comm_name); c++) | 444 | for (c = 0; c <= strlen (comm_name); c++) |
436 | comm_name[c] = toupper(comm_name[c]); | 445 | comm_name[c] = toupper (comm_name[c]); |
437 | if (0 == strcmp(comm_name, "CORE")) | 446 | if (0 == strcmp (comm_name, "CORE")) |
438 | test_core = GNUNET_YES; | 447 | test_core = GNUNET_YES; |
439 | else if (0 == strcmp(comm_name, "TRANSPORT")) | 448 | else if (0 == strcmp (comm_name, "TRANSPORT")) |
440 | test_core = GNUNET_NO; | 449 | test_core = GNUNET_NO; |
441 | else | 450 | else |
442 | { | 451 | { |
443 | GNUNET_free(comm_name); | 452 | GNUNET_free (comm_name); |
444 | GNUNET_free(solver); | 453 | GNUNET_free (solver); |
445 | return GNUNET_SYSERR; | 454 | return GNUNET_SYSERR; |
446 | } | 455 | } |
447 | 456 | ||
448 | pref_str = GNUNET_strdup(tmp_sep + 1); | 457 | pref_str = GNUNET_strdup (tmp_sep + 1); |
449 | 458 | ||
450 | GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, | 459 | GNUNET_asprintf (&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, |
451 | pref_str); | 460 | pref_str); |
452 | GNUNET_asprintf(&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str); | 461 | GNUNET_asprintf (&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str); |
453 | 462 | ||
454 | for (c = 0; c <= strlen(pref_str); c++) | 463 | for (c = 0; c <= strlen (pref_str); c++) |
455 | pref_str[c] = toupper(pref_str[c]); | 464 | pref_str[c] = toupper (pref_str[c]); |
456 | pref_val = -1; | 465 | pref_val = -1; |
457 | 466 | ||
458 | if (0 != strcmp(pref_str, "NONE")) | 467 | if (0 != strcmp (pref_str, "NONE")) |
468 | { | ||
469 | for (c = 0; c < GNUNET_ATS_PREFERENCE_END; c++) | ||
459 | { | 470 | { |
460 | for (c = 0; c < GNUNET_ATS_PREFERENCE_END; c++) | 471 | if (0 == strcmp (pref_str, prefs[c])) |
461 | { | 472 | { |
462 | if (0 == strcmp(pref_str, prefs[c])) | 473 | pref_val = c; |
463 | { | 474 | break; |
464 | pref_val = c; | 475 | } |
465 | break; | ||
466 | } | ||
467 | } | ||
468 | } | 476 | } |
477 | } | ||
469 | else | 478 | else |
470 | { | 479 | { |
471 | /* abuse terminator to indicate no pref */ | 480 | /* abuse terminator to indicate no pref */ |
472 | pref_val = GNUNET_ATS_PREFERENCE_END; | 481 | pref_val = GNUNET_ATS_PREFERENCE_END; |
473 | } | 482 | } |
474 | if (-1 == pref_val) | 483 | if (-1 == pref_val) |
475 | { | 484 | { |
476 | fprintf(stderr, "Unknown preference: `%s'\n", pref_str); | 485 | fprintf (stderr, "Unknown preference: `%s'\n", pref_str); |
477 | GNUNET_free(solver); | 486 | GNUNET_free (solver); |
478 | GNUNET_free(pref_str); | 487 | GNUNET_free (pref_str); |
479 | GNUNET_free(comm_name); | 488 | GNUNET_free (comm_name); |
480 | return -1; | 489 | return -1; |
481 | } | 490 | } |
482 | 491 | ||
483 | for (c = 0; c < (argc - 1); c++) | 492 | for (c = 0; c < (argc - 1); c++) |
484 | { | 493 | { |
485 | if (0 == strcmp(argv[c], "-d")) | 494 | if (0 == strcmp (argv[c], "-d")) |
486 | break; | 495 | break; |
487 | } | 496 | } |
488 | if (c < argc - 1) | 497 | if (c < argc - 1) |
489 | { | 498 | { |
490 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative(argv[c + 1], &perf_duration)) | 499 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], |
491 | fprintf(stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | 500 | &perf_duration)) |
492 | } | 501 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); |
502 | } | ||
493 | else | 503 | else |
494 | { | 504 | { |
495 | perf_duration = BENCHMARK_DURATION; | 505 | perf_duration = BENCHMARK_DURATION; |
496 | } | 506 | } |
497 | fprintf(stderr, "Running benchmark for %llu secs\n", (unsigned long long)(perf_duration.rel_value_us) / (1000 * 1000)); | 507 | fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long |
508 | long) (perf_duration. | ||
509 | rel_value_us) | ||
510 | / (1000 * 1000)); | ||
498 | 511 | ||
499 | for (c = 0; c < (argc - 1); c++) | 512 | for (c = 0; c < (argc - 1); c++) |
500 | { | 513 | { |
501 | if (0 == strcmp(argv[c], "-s")) | 514 | if (0 == strcmp (argv[c], "-s")) |
502 | break; | 515 | break; |
503 | } | 516 | } |
504 | if (c < argc - 1) | 517 | if (c < argc - 1) |
505 | { | 518 | { |
506 | if ((0L != (num_slaves = strtol(argv[c + 1], NULL, 10))) | 519 | if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10))) |
507 | && (num_slaves >= 1)) | 520 | && (num_slaves >= 1)) |
508 | fprintf(stderr, "Starting %u slave peers\n", num_slaves); | 521 | fprintf (stderr, "Starting %u slave peers\n", num_slaves); |
509 | else | 522 | else |
510 | num_slaves = DEFAULT_SLAVES_NUM; | 523 | num_slaves = DEFAULT_SLAVES_NUM; |
511 | } | 524 | } |
512 | else | 525 | else |
513 | num_slaves = DEFAULT_SLAVES_NUM; | 526 | num_slaves = DEFAULT_SLAVES_NUM; |
514 | 527 | ||
515 | for (c = 0; c < (argc - 1); c++) | 528 | for (c = 0; c < (argc - 1); c++) |
516 | { | 529 | { |
517 | if (0 == strcmp(argv[c], "-m")) | 530 | if (0 == strcmp (argv[c], "-m")) |
518 | break; | 531 | break; |
519 | } | 532 | } |
520 | if (c < argc - 1) | 533 | if (c < argc - 1) |
521 | { | 534 | { |
522 | if ((0L != (num_masters = strtol(argv[c + 1], NULL, 10))) | 535 | if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10))) |
523 | && (num_masters >= 2)) | 536 | && (num_masters >= 2)) |
524 | fprintf(stderr, "Starting %u master peers\n", num_masters); | 537 | fprintf (stderr, "Starting %u master peers\n", num_masters); |
525 | else | 538 | else |
526 | num_masters = DEFAULT_MASTERS_NUM; | 539 | num_masters = DEFAULT_MASTERS_NUM; |
527 | } | 540 | } |
528 | else | 541 | else |
529 | num_masters = DEFAULT_MASTERS_NUM; | 542 | num_masters = DEFAULT_MASTERS_NUM; |
530 | 543 | ||
531 | logging = GNUNET_NO; | 544 | logging = GNUNET_NO; |
532 | for (c = 0; c < argc; c++) | 545 | for (c = 0; c < argc; c++) |
533 | { | 546 | { |
534 | if (0 == strcmp(argv[c], "-l")) | 547 | if (0 == strcmp (argv[c], "-l")) |
535 | logging = GNUNET_YES; | 548 | logging = GNUNET_YES; |
536 | } | 549 | } |
537 | 550 | ||
538 | if (GNUNET_YES == logging) | 551 | if (GNUNET_YES == logging) |
552 | { | ||
553 | for (c = 0; c < (argc - 1); c++) | ||
554 | { | ||
555 | if (0 == strcmp (argv[c], "-f")) | ||
556 | break; | ||
557 | } | ||
558 | if (c < argc - 1) | ||
559 | { | ||
560 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], | ||
561 | &log_frequency)) | ||
562 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
563 | } | ||
564 | else | ||
539 | { | 565 | { |
540 | for (c = 0; c < (argc - 1); c++) | 566 | log_frequency = LOGGING_FREQUENCY; |
541 | { | ||
542 | if (0 == strcmp(argv[c], "-f")) | ||
543 | break; | ||
544 | } | ||
545 | if (c < argc - 1) | ||
546 | { | ||
547 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative(argv[c + 1], &log_frequency)) | ||
548 | fprintf(stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | log_frequency = LOGGING_FREQUENCY; | ||
553 | } | ||
554 | fprintf(stderr, "Using log frequency %llu ms\n", | ||
555 | (unsigned long long)(log_frequency.rel_value_us) / (1000)); | ||
556 | } | 567 | } |
568 | fprintf (stderr, "Using log frequency %llu ms\n", | ||
569 | (unsigned long long) (log_frequency.rel_value_us) / (1000)); | ||
570 | } | ||
557 | 571 | ||
558 | GNUNET_asprintf(&testname, "%s_%s_%s", solver, comm_name, pref_str); | 572 | GNUNET_asprintf (&testname, "%s_%s_%s", solver, comm_name, pref_str); |
559 | 573 | ||
560 | if (num_slaves < num_masters) | 574 | if (num_slaves < num_masters) |
561 | { | 575 | { |
562 | fprintf(stderr, | 576 | fprintf (stderr, |
563 | "Number of master peers is lower than slaves! exit...\n"); | 577 | "Number of master peers is lower than slaves! exit...\n"); |
564 | GNUNET_free(test_name); | 578 | GNUNET_free (test_name); |
565 | GNUNET_free(solver); | 579 | GNUNET_free (solver); |
566 | GNUNET_free(pref_str); | 580 | GNUNET_free (pref_str); |
567 | GNUNET_free(comm_name); | 581 | GNUNET_free (comm_name); |
568 | return GNUNET_SYSERR; | 582 | return GNUNET_SYSERR; |
569 | } | 583 | } |
570 | 584 | ||
571 | /** | 585 | /** |
572 | * Setup the topology | 586 | * Setup the topology |
573 | */ | 587 | */ |
574 | GNUNET_ATS_TEST_create_topology("perf-ats", | 588 | GNUNET_ATS_TEST_create_topology ("perf-ats", |
575 | conf_name, | 589 | conf_name, |
576 | num_slaves, | 590 | num_slaves, |
577 | num_masters, | 591 | num_masters, |
578 | test_core, | 592 | test_core, |
579 | &do_benchmark, | 593 | &do_benchmark, |
580 | NULL, | 594 | NULL, |
581 | &log_request_cb); | 595 | &log_request_cb); |
582 | 596 | ||
583 | return result; | 597 | return result; |
584 | } | 598 | } |