diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/gns/gnunet-gns-benchmark.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/gns/gnunet-gns-benchmark.c')
-rw-r--r-- | src/gns/gnunet-gns-benchmark.c | 522 |
1 files changed, 264 insertions, 258 deletions
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c index b64201f10..d85b9e203 100644 --- a/src/gns/gnunet-gns-benchmark.c +++ b/src/gns/gnunet-gns-benchmark.c | |||
@@ -31,12 +31,13 @@ | |||
31 | /** | 31 | /** |
32 | * How long do we wait at least between requests by default? | 32 | * How long do we wait at least between requests by default? |
33 | */ | 33 | */ |
34 | #define DEF_REQUEST_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1) | 34 | #define DEF_REQUEST_DELAY GNUNET_TIME_relative_multiply ( \ |
35 | GNUNET_TIME_UNIT_MILLISECONDS, 1) | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * How long do we wait until we consider a request failed by default? | 38 | * How long do we wait until we consider a request failed by default? |
38 | */ | 39 | */ |
39 | #define DEF_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) | 40 | #define DEF_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1) |
40 | 41 | ||
41 | 42 | ||
42 | /** | 43 | /** |
@@ -45,7 +46,8 @@ | |||
45 | * However, this process does not change how it acts | 46 | * However, this process does not change how it acts |
46 | * based on the category. | 47 | * based on the category. |
47 | */ | 48 | */ |
48 | enum RequestCategory { | 49 | enum RequestCategory |
50 | { | ||
49 | RC_SHARED = 0, | 51 | RC_SHARED = 0, |
50 | RC_PRIVATE = 1, | 52 | RC_PRIVATE = 1, |
51 | /** | 53 | /** |
@@ -60,7 +62,8 @@ enum RequestCategory { | |||
60 | * thus optimizing it is crucial for the overall memory consumption of | 62 | * thus optimizing it is crucial for the overall memory consumption of |
61 | * the zone importer. | 63 | * the zone importer. |
62 | */ | 64 | */ |
63 | struct Request { | 65 | struct Request |
66 | { | ||
64 | /** | 67 | /** |
65 | * Active requests are kept in a DLL. | 68 | * Active requests are kept in a DLL. |
66 | */ | 69 | */ |
@@ -188,11 +191,11 @@ static int g2d; | |||
188 | * @param req request to free | 191 | * @param req request to free |
189 | */ | 192 | */ |
190 | static void | 193 | static void |
191 | free_request(struct Request *req) | 194 | free_request (struct Request *req) |
192 | { | 195 | { |
193 | if (NULL != req->lr) | 196 | if (NULL != req->lr) |
194 | GNUNET_GNS_lookup_with_tld_cancel(req->lr); | 197 | GNUNET_GNS_lookup_with_tld_cancel (req->lr); |
195 | GNUNET_free(req); | 198 | GNUNET_free (req); |
196 | } | 199 | } |
197 | 200 | ||
198 | 201 | ||
@@ -205,32 +208,32 @@ free_request(struct Request *req) | |||
205 | * @param rd the records in reply | 208 | * @param rd the records in reply |
206 | */ | 209 | */ |
207 | static void | 210 | static void |
208 | process_result(void *cls, | 211 | process_result (void *cls, |
209 | int gns_tld, | 212 | int gns_tld, |
210 | uint32_t rd_count, | 213 | uint32_t rd_count, |
211 | const struct GNUNET_GNSRECORD_Data *rd) | 214 | const struct GNUNET_GNSRECORD_Data *rd) |
212 | { | 215 | { |
213 | struct Request *req = cls; | 216 | struct Request *req = cls; |
214 | 217 | ||
215 | (void)gns_tld; | 218 | (void) gns_tld; |
216 | (void)rd_count; | 219 | (void) rd_count; |
217 | (void)rd; | 220 | (void) rd; |
218 | active_cnt--; | 221 | active_cnt--; |
219 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
220 | "Got response for request `%s'\n", | 223 | "Got response for request `%s'\n", |
221 | req->hostname); | 224 | req->hostname); |
222 | req->lr = NULL; | 225 | req->lr = NULL; |
223 | req->latency = GNUNET_TIME_absolute_get_duration(req->op_start_time); | 226 | req->latency = GNUNET_TIME_absolute_get_duration (req->op_start_time); |
224 | GNUNET_CONTAINER_DLL_remove(act_head, | 227 | GNUNET_CONTAINER_DLL_remove (act_head, |
225 | act_tail, | 228 | act_tail, |
226 | req); | 229 | req); |
227 | GNUNET_CONTAINER_DLL_insert(succ_head, | 230 | GNUNET_CONTAINER_DLL_insert (succ_head, |
228 | succ_tail, | 231 | succ_tail, |
229 | req); | 232 | req); |
230 | replies[req->cat]++; | 233 | replies[req->cat]++; |
231 | latency_sum[req->cat] | 234 | latency_sum[req->cat] |
232 | = GNUNET_TIME_relative_add(latency_sum[req->cat], | 235 | = GNUNET_TIME_relative_add (latency_sum[req->cat], |
233 | req->latency); | 236 | req->latency); |
234 | } | 237 | } |
235 | 238 | ||
236 | 239 | ||
@@ -240,69 +243,69 @@ process_result(void *cls, | |||
240 | * @param cls NULL | 243 | * @param cls NULL |
241 | */ | 244 | */ |
242 | static void | 245 | static void |
243 | process_queue(void *cls) | 246 | process_queue (void *cls) |
244 | { | 247 | { |
245 | struct Request *req; | 248 | struct Request *req; |
246 | struct GNUNET_TIME_Relative duration; | 249 | struct GNUNET_TIME_Relative duration; |
247 | 250 | ||
248 | (void)cls; | 251 | (void) cls; |
249 | t = NULL; | 252 | t = NULL; |
250 | /* check for expired requests */ | 253 | /* check for expired requests */ |
251 | while (NULL != (req = act_head)) | 254 | while (NULL != (req = act_head)) |
252 | { | 255 | { |
253 | duration = GNUNET_TIME_absolute_get_duration(req->op_start_time); | 256 | duration = GNUNET_TIME_absolute_get_duration (req->op_start_time); |
254 | if (duration.rel_value_us < timeout.rel_value_us) | 257 | if (duration.rel_value_us < timeout.rel_value_us) |
255 | break; | 258 | break; |
256 | GNUNET_CONTAINER_DLL_remove(act_head, | 259 | GNUNET_CONTAINER_DLL_remove (act_head, |
257 | act_tail, | 260 | act_tail, |
258 | req); | 261 | req); |
259 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
260 | "Failing request `%s' due to timeout\n", | 263 | "Failing request `%s' due to timeout\n", |
261 | req->hostname); | 264 | req->hostname); |
262 | failures[req->cat]++; | 265 | failures[req->cat]++; |
263 | active_cnt--; | 266 | active_cnt--; |
264 | free_request(req); | 267 | free_request (req); |
265 | } | 268 | } |
266 | if (NULL == (req = todo_head)) | 269 | if (NULL == (req = todo_head)) |
270 | { | ||
271 | struct GNUNET_TIME_Absolute at; | ||
272 | |||
273 | if (NULL == (req = act_head)) | ||
267 | { | 274 | { |
268 | struct GNUNET_TIME_Absolute at; | 275 | GNUNET_SCHEDULER_shutdown (); |
269 | |||
270 | if (NULL == (req = act_head)) | ||
271 | { | ||
272 | GNUNET_SCHEDULER_shutdown(); | ||
273 | return; | ||
274 | } | ||
275 | at = GNUNET_TIME_absolute_add(req->op_start_time, | ||
276 | timeout); | ||
277 | t = GNUNET_SCHEDULER_add_at(at, | ||
278 | &process_queue, | ||
279 | NULL); | ||
280 | return; | 276 | return; |
281 | } | 277 | } |
282 | GNUNET_CONTAINER_DLL_remove(todo_head, | 278 | at = GNUNET_TIME_absolute_add (req->op_start_time, |
283 | todo_tail, | 279 | timeout); |
284 | req); | 280 | t = GNUNET_SCHEDULER_add_at (at, |
285 | GNUNET_CONTAINER_DLL_insert_tail(act_head, | 281 | &process_queue, |
286 | act_tail, | 282 | NULL); |
287 | req); | 283 | return; |
284 | } | ||
285 | GNUNET_CONTAINER_DLL_remove (todo_head, | ||
286 | todo_tail, | ||
287 | req); | ||
288 | GNUNET_CONTAINER_DLL_insert_tail (act_head, | ||
289 | act_tail, | ||
290 | req); | ||
288 | lookups[req->cat]++; | 291 | lookups[req->cat]++; |
289 | active_cnt++; | 292 | active_cnt++; |
290 | req->op_start_time = GNUNET_TIME_absolute_get(); | 293 | req->op_start_time = GNUNET_TIME_absolute_get (); |
291 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
292 | "Starting request `%s' (%u in parallel)\n", | 295 | "Starting request `%s' (%u in parallel)\n", |
293 | req->hostname, | 296 | req->hostname, |
294 | active_cnt); | 297 | active_cnt); |
295 | req->lr = GNUNET_GNS_lookup_with_tld(gns, | 298 | req->lr = GNUNET_GNS_lookup_with_tld (gns, |
296 | req->hostname, | 299 | req->hostname, |
297 | g2d | 300 | g2d |
298 | ? GNUNET_GNSRECORD_TYPE_GNS2DNS | 301 | ? GNUNET_GNSRECORD_TYPE_GNS2DNS |
299 | : GNUNET_GNSRECORD_TYPE_ANY, | 302 | : GNUNET_GNSRECORD_TYPE_ANY, |
300 | GNUNET_GNS_LO_DEFAULT, | 303 | GNUNET_GNS_LO_DEFAULT, |
301 | &process_result, | 304 | &process_result, |
302 | req); | 305 | req); |
303 | t = GNUNET_SCHEDULER_add_delayed(request_delay, | 306 | t = GNUNET_SCHEDULER_add_delayed (request_delay, |
304 | &process_queue, | 307 | &process_queue, |
305 | NULL); | 308 | NULL); |
306 | } | 309 | } |
307 | 310 | ||
308 | 311 | ||
@@ -314,11 +317,11 @@ process_queue(void *cls) | |||
314 | * @return -1 if c1<c2, 1 if c1>c2, 0 if c1==c2. | 317 | * @return -1 if c1<c2, 1 if c1>c2, 0 if c1==c2. |
315 | */ | 318 | */ |
316 | static int | 319 | static int |
317 | compare_req(const void *c1, | 320 | compare_req (const void *c1, |
318 | const void *c2) | 321 | const void *c2) |
319 | { | 322 | { |
320 | const struct Request *r1 = *(void **)c1; | 323 | const struct Request *r1 = *(void **) c1; |
321 | const struct Request *r2 = *(void **)c2; | 324 | const struct Request *r2 = *(void **) c2; |
322 | 325 | ||
323 | if (r1->latency.rel_value_us < r2->latency.rel_value_us) | 326 | if (r1->latency.rel_value_us < r2->latency.rel_value_us) |
324 | return -1; | 327 | return -1; |
@@ -334,101 +337,101 @@ compare_req(const void *c1, | |||
334 | * @param cls NULL | 337 | * @param cls NULL |
335 | */ | 338 | */ |
336 | static void | 339 | static void |
337 | do_shutdown(void *cls) | 340 | do_shutdown (void *cls) |
338 | { | 341 | { |
339 | struct Request *req; | 342 | struct Request *req; |
340 | struct Request **ra[RC_MAX]; | 343 | struct Request **ra[RC_MAX]; |
341 | unsigned int rp[RC_MAX]; | 344 | unsigned int rp[RC_MAX]; |
342 | 345 | ||
343 | (void)cls; | 346 | (void) cls; |
344 | for (enum RequestCategory rc = 0; rc < RC_MAX; rc++) | 347 | for (enum RequestCategory rc = 0; rc < RC_MAX; rc++) |
345 | { | 348 | { |
346 | ra[rc] = GNUNET_new_array(replies[rc], | 349 | ra[rc] = GNUNET_new_array (replies[rc], |
347 | struct Request *); | 350 | struct Request *); |
348 | rp[rc] = 0; | 351 | rp[rc] = 0; |
349 | } | 352 | } |
350 | for (req = succ_head; NULL != req; req = req->next) | 353 | for (req = succ_head; NULL != req; req = req->next) |
351 | { | 354 | { |
352 | GNUNET_assert(rp[req->cat] < replies[req->cat]); | 355 | GNUNET_assert (rp[req->cat] < replies[req->cat]); |
353 | ra[req->cat][rp[req->cat]++] = req; | 356 | ra[req->cat][rp[req->cat]++] = req; |
354 | } | 357 | } |
355 | for (enum RequestCategory rc = 0; rc < RC_MAX; rc++) | 358 | for (enum RequestCategory rc = 0; rc < RC_MAX; rc++) |
356 | { | 359 | { |
357 | unsigned int off; | 360 | unsigned int off; |
358 | 361 | ||
359 | fprintf(stdout, | 362 | fprintf (stdout, |
360 | "Category %u\n", | 363 | "Category %u\n", |
361 | rc); | 364 | rc); |
362 | fprintf(stdout, | 365 | fprintf (stdout, |
363 | "\tlookups: %u replies: %u failures: %u\n", | 366 | "\tlookups: %u replies: %u failures: %u\n", |
364 | lookups[rc], | 367 | lookups[rc], |
365 | replies[rc], | 368 | replies[rc], |
366 | failures[rc]); | 369 | failures[rc]); |
367 | if (0 == rp[rc]) | 370 | if (0 == rp[rc]) |
368 | continue; | 371 | continue; |
369 | qsort(ra[rc], | 372 | qsort (ra[rc], |
370 | rp[rc], | 373 | rp[rc], |
371 | sizeof(struct Request *), | 374 | sizeof(struct Request *), |
372 | &compare_req); | 375 | &compare_req); |
373 | latency_sum[rc] = GNUNET_TIME_relative_divide(latency_sum[rc], | 376 | latency_sum[rc] = GNUNET_TIME_relative_divide (latency_sum[rc], |
374 | replies[rc]); | 377 | replies[rc]); |
375 | fprintf(stdout, | 378 | fprintf (stdout, |
376 | "\taverage: %s\n", | 379 | "\taverage: %s\n", |
377 | GNUNET_STRINGS_relative_time_to_string(latency_sum[rc], | 380 | GNUNET_STRINGS_relative_time_to_string (latency_sum[rc], |
378 | GNUNET_YES)); | 381 | GNUNET_YES)); |
379 | off = rp[rc] * 50 / 100; | 382 | off = rp[rc] * 50 / 100; |
380 | fprintf(stdout, | 383 | fprintf (stdout, |
381 | "\tmedian(50): %s\n", | 384 | "\tmedian(50): %s\n", |
382 | GNUNET_STRINGS_relative_time_to_string(ra[rc][off]->latency, | 385 | GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency, |
383 | GNUNET_YES)); | 386 | GNUNET_YES)); |
384 | off = rp[rc] * 75 / 100; | 387 | off = rp[rc] * 75 / 100; |
385 | fprintf(stdout, | 388 | fprintf (stdout, |
386 | "\tquantile(75): %s\n", | 389 | "\tquantile(75): %s\n", |
387 | GNUNET_STRINGS_relative_time_to_string(ra[rc][off]->latency, | 390 | GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency, |
388 | GNUNET_YES)); | 391 | GNUNET_YES)); |
389 | off = rp[rc] * 90 / 100; | 392 | off = rp[rc] * 90 / 100; |
390 | fprintf(stdout, | 393 | fprintf (stdout, |
391 | "\tquantile(90): %s\n", | 394 | "\tquantile(90): %s\n", |
392 | GNUNET_STRINGS_relative_time_to_string(ra[rc][off]->latency, | 395 | GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency, |
393 | GNUNET_YES)); | 396 | GNUNET_YES)); |
394 | off = rp[rc] * 99 / 100; | 397 | off = rp[rc] * 99 / 100; |
395 | fprintf(stdout, | 398 | fprintf (stdout, |
396 | "\tquantile(99): %s\n", | 399 | "\tquantile(99): %s\n", |
397 | GNUNET_STRINGS_relative_time_to_string(ra[rc][off]->latency, | 400 | GNUNET_STRINGS_relative_time_to_string (ra[rc][off]->latency, |
398 | GNUNET_YES)); | 401 | GNUNET_YES)); |
399 | GNUNET_free(ra[rc]); | 402 | GNUNET_free (ra[rc]); |
400 | } | 403 | } |
401 | if (NULL != t) | 404 | if (NULL != t) |
402 | { | 405 | { |
403 | GNUNET_SCHEDULER_cancel(t); | 406 | GNUNET_SCHEDULER_cancel (t); |
404 | t = NULL; | 407 | t = NULL; |
405 | } | 408 | } |
406 | while (NULL != (req = act_head)) | 409 | while (NULL != (req = act_head)) |
407 | { | 410 | { |
408 | GNUNET_CONTAINER_DLL_remove(act_head, | 411 | GNUNET_CONTAINER_DLL_remove (act_head, |
409 | act_tail, | 412 | act_tail, |
410 | req); | 413 | req); |
411 | free_request(req); | 414 | free_request (req); |
412 | } | 415 | } |
413 | while (NULL != (req = succ_head)) | 416 | while (NULL != (req = succ_head)) |
414 | { | 417 | { |
415 | GNUNET_CONTAINER_DLL_remove(succ_head, | 418 | GNUNET_CONTAINER_DLL_remove (succ_head, |
416 | succ_tail, | 419 | succ_tail, |
417 | req); | 420 | req); |
418 | free_request(req); | 421 | free_request (req); |
419 | } | 422 | } |
420 | while (NULL != (req = todo_head)) | 423 | while (NULL != (req = todo_head)) |
421 | { | 424 | { |
422 | GNUNET_CONTAINER_DLL_remove(todo_head, | 425 | GNUNET_CONTAINER_DLL_remove (todo_head, |
423 | todo_tail, | 426 | todo_tail, |
424 | req); | 427 | req); |
425 | free_request(req); | 428 | free_request (req); |
426 | } | 429 | } |
427 | if (NULL != gns) | 430 | if (NULL != gns) |
428 | { | 431 | { |
429 | GNUNET_GNS_disconnect(gns); | 432 | GNUNET_GNS_disconnect (gns); |
430 | gns = NULL; | 433 | gns = NULL; |
431 | } | 434 | } |
432 | } | 435 | } |
433 | 436 | ||
434 | 437 | ||
@@ -439,32 +442,32 @@ do_shutdown(void *cls) | |||
439 | * @param cat category of the @a hostname | 442 | * @param cat category of the @a hostname |
440 | */ | 443 | */ |
441 | static void | 444 | static void |
442 | queue(const char *hostname, | 445 | queue (const char *hostname, |
443 | enum RequestCategory cat) | 446 | enum RequestCategory cat) |
444 | { | 447 | { |
445 | struct Request *req; | 448 | struct Request *req; |
446 | const char *dot; | 449 | const char *dot; |
447 | size_t hlen; | 450 | size_t hlen; |
448 | 451 | ||
449 | dot = strchr(hostname, | 452 | dot = strchr (hostname, |
450 | (unsigned char)'.'); | 453 | (unsigned char) '.'); |
451 | if (NULL == dot) | 454 | if (NULL == dot) |
452 | { | 455 | { |
453 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 456 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
454 | "Refusing invalid hostname `%s' (lacks '.')\n", | 457 | "Refusing invalid hostname `%s' (lacks '.')\n", |
455 | hostname); | 458 | hostname); |
456 | return; | 459 | return; |
457 | } | 460 | } |
458 | hlen = strlen(hostname) + 1; | 461 | hlen = strlen (hostname) + 1; |
459 | req = GNUNET_malloc(sizeof(struct Request) + hlen); | 462 | req = GNUNET_malloc (sizeof(struct Request) + hlen); |
460 | req->cat = cat; | 463 | req->cat = cat; |
461 | req->hostname = (char *)&req[1]; | 464 | req->hostname = (char *) &req[1]; |
462 | GNUNET_memcpy(&req[1], | 465 | GNUNET_memcpy (&req[1], |
463 | hostname, | 466 | hostname, |
464 | hlen); | 467 | hlen); |
465 | GNUNET_CONTAINER_DLL_insert(todo_head, | 468 | GNUNET_CONTAINER_DLL_insert (todo_head, |
466 | todo_tail, | 469 | todo_tail, |
467 | req); | 470 | req); |
468 | } | 471 | } |
469 | 472 | ||
470 | 473 | ||
@@ -474,7 +477,7 @@ queue(const char *hostname, | |||
474 | * @param cls NULL | 477 | * @param cls NULL |
475 | */ | 478 | */ |
476 | static void | 479 | static void |
477 | process_stdin(void *cls) | 480 | process_stdin (void *cls) |
478 | { | 481 | { |
479 | static struct GNUNET_TIME_Absolute last; | 482 | static struct GNUNET_TIME_Absolute last; |
480 | static uint64_t idot; | 483 | static uint64_t idot; |
@@ -482,48 +485,48 @@ process_stdin(void *cls) | |||
482 | char hn[256]; | 485 | char hn[256]; |
483 | char in[270]; | 486 | char in[270]; |
484 | 487 | ||
485 | (void)cls; | 488 | (void) cls; |
486 | t = NULL; | 489 | t = NULL; |
487 | while (NULL != | 490 | while (NULL != |
488 | fgets(in, | 491 | fgets (in, |
489 | sizeof(in), | 492 | sizeof(in), |
490 | stdin)) | 493 | stdin)) |
494 | { | ||
495 | if (strlen (in) > 0) | ||
496 | hn[strlen (in) - 1] = '\0'; /* eat newline */ | ||
497 | if ((2 != sscanf (in, | ||
498 | "%u %255s", | ||
499 | &cat, | ||
500 | hn)) || | ||
501 | (cat >= RC_MAX)) | ||
491 | { | 502 | { |
492 | if (strlen(in) > 0) | 503 | fprintf (stderr, |
493 | hn[strlen(in) - 1] = '\0'; /* eat newline */ | 504 | "Malformed input line `%s', skipping\n", |
494 | if ((2 != sscanf(in, | 505 | in); |
495 | "%u %255s", | 506 | continue; |
496 | &cat, | ||
497 | hn)) || | ||
498 | (cat >= RC_MAX)) | ||
499 | { | ||
500 | fprintf(stderr, | ||
501 | "Malformed input line `%s', skipping\n", | ||
502 | in); | ||
503 | continue; | ||
504 | } | ||
505 | if (0 == idot) | ||
506 | last = GNUNET_TIME_absolute_get(); | ||
507 | idot++; | ||
508 | if (0 == idot % 100000) | ||
509 | { | ||
510 | struct GNUNET_TIME_Relative delta; | ||
511 | |||
512 | delta = GNUNET_TIME_absolute_get_duration(last); | ||
513 | last = GNUNET_TIME_absolute_get(); | ||
514 | fprintf(stderr, | ||
515 | "Read 100000 domain names in %s\n", | ||
516 | GNUNET_STRINGS_relative_time_to_string(delta, | ||
517 | GNUNET_YES)); | ||
518 | } | ||
519 | queue(hn, | ||
520 | (enum RequestCategory)cat); | ||
521 | } | 507 | } |
522 | fprintf(stderr, | 508 | if (0 == idot) |
523 | "Done reading %llu domain names\n", | 509 | last = GNUNET_TIME_absolute_get (); |
524 | (unsigned long long)idot); | 510 | idot++; |
525 | t = GNUNET_SCHEDULER_add_now(&process_queue, | 511 | if (0 == idot % 100000) |
526 | NULL); | 512 | { |
513 | struct GNUNET_TIME_Relative delta; | ||
514 | |||
515 | delta = GNUNET_TIME_absolute_get_duration (last); | ||
516 | last = GNUNET_TIME_absolute_get (); | ||
517 | fprintf (stderr, | ||
518 | "Read 100000 domain names in %s\n", | ||
519 | GNUNET_STRINGS_relative_time_to_string (delta, | ||
520 | GNUNET_YES)); | ||
521 | } | ||
522 | queue (hn, | ||
523 | (enum RequestCategory) cat); | ||
524 | } | ||
525 | fprintf (stderr, | ||
526 | "Done reading %llu domain names\n", | ||
527 | (unsigned long long) idot); | ||
528 | t = GNUNET_SCHEDULER_add_now (&process_queue, | ||
529 | NULL); | ||
527 | } | 530 | } |
528 | 531 | ||
529 | 532 | ||
@@ -537,25 +540,25 @@ process_stdin(void *cls) | |||
537 | * @param cfg configuration | 540 | * @param cfg configuration |
538 | */ | 541 | */ |
539 | static void | 542 | static void |
540 | run(void *cls, | 543 | run (void *cls, |
541 | char *const *args, | 544 | char *const *args, |
542 | const char *cfgfile, | 545 | const char *cfgfile, |
543 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 546 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
544 | { | 547 | { |
545 | (void)cls; | 548 | (void) cls; |
546 | (void)args; | 549 | (void) args; |
547 | (void)cfgfile; | 550 | (void) cfgfile; |
548 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, | 551 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
549 | NULL); | 552 | NULL); |
550 | gns = GNUNET_GNS_connect(cfg); | 553 | gns = GNUNET_GNS_connect (cfg); |
551 | if (NULL == gns) | 554 | if (NULL == gns) |
552 | { | 555 | { |
553 | GNUNET_break(0); | 556 | GNUNET_break (0); |
554 | GNUNET_SCHEDULER_shutdown(); | 557 | GNUNET_SCHEDULER_shutdown (); |
555 | return; | 558 | return; |
556 | } | 559 | } |
557 | t = GNUNET_SCHEDULER_add_now(&process_stdin, | 560 | t = GNUNET_SCHEDULER_add_now (&process_stdin, |
558 | NULL); | 561 | NULL); |
559 | } | 562 | } |
560 | 563 | ||
561 | 564 | ||
@@ -567,44 +570,47 @@ run(void *cls, | |||
567 | * @return 0 on success | 570 | * @return 0 on success |
568 | */ | 571 | */ |
569 | int | 572 | int |
570 | main(int argc, | 573 | main (int argc, |
571 | char *const*argv) | 574 | char *const*argv) |
572 | { | 575 | { |
573 | int ret = 0; | 576 | int ret = 0; |
574 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 577 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
575 | GNUNET_GETOPT_option_relative_time('d', | 578 | GNUNET_GETOPT_option_relative_time ('d', |
576 | "delay", | 579 | "delay", |
577 | "RELATIVETIME", | 580 | "RELATIVETIME", |
578 | gettext_noop("how long to wait between queries"), | 581 | gettext_noop ( |
579 | &request_delay), | 582 | "how long to wait between queries"), |
580 | GNUNET_GETOPT_option_relative_time('t', | 583 | &request_delay), |
581 | "timeout", | 584 | GNUNET_GETOPT_option_relative_time ('t', |
582 | "RELATIVETIME", | 585 | "timeout", |
583 | gettext_noop("how long to wait for an answer"), | 586 | "RELATIVETIME", |
584 | &timeout), | 587 | gettext_noop ( |
585 | GNUNET_GETOPT_option_flag('2', | 588 | "how long to wait for an answer"), |
586 | "g2d", | 589 | &timeout), |
587 | gettext_noop("look for GNS2DNS records instead of ANY"), | 590 | GNUNET_GETOPT_option_flag ('2', |
588 | &g2d), | 591 | "g2d", |
592 | gettext_noop ( | ||
593 | "look for GNS2DNS records instead of ANY"), | ||
594 | &g2d), | ||
589 | GNUNET_GETOPT_OPTION_END | 595 | GNUNET_GETOPT_OPTION_END |
590 | }; | 596 | }; |
591 | 597 | ||
592 | if (GNUNET_OK != | 598 | if (GNUNET_OK != |
593 | GNUNET_STRINGS_get_utf8_args(argc, argv, | 599 | GNUNET_STRINGS_get_utf8_args (argc, argv, |
594 | &argc, &argv)) | 600 | &argc, &argv)) |
595 | return 2; | 601 | return 2; |
596 | timeout = DEF_TIMEOUT; | 602 | timeout = DEF_TIMEOUT; |
597 | request_delay = DEF_REQUEST_DELAY; | 603 | request_delay = DEF_REQUEST_DELAY; |
598 | if (GNUNET_OK != | 604 | if (GNUNET_OK != |
599 | GNUNET_PROGRAM_run(argc, | 605 | GNUNET_PROGRAM_run (argc, |
600 | argv, | 606 | argv, |
601 | "gnunet-gns-benchmark", | 607 | "gnunet-gns-benchmark", |
602 | "resolve GNS names and measure performance", | 608 | "resolve GNS names and measure performance", |
603 | options, | 609 | options, |
604 | &run, | 610 | &run, |
605 | NULL)) | 611 | NULL)) |
606 | ret = 1; | 612 | ret = 1; |
607 | GNUNET_free((void*)argv); | 613 | GNUNET_free ((void*) argv); |
608 | return ret; | 614 | return ret; |
609 | } | 615 | } |
610 | 616 | ||