Lines Matching +full:1000 +full:base +full:- +full:x

2  * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson
26 #include "../util-internal.h"
66 static int cfg_tick_msec = 1000;
67 static int cfg_min_share = -1;
70 static int cfg_connlimit_tolerance = -1;
71 static int cfg_grouplimit_tolerance = -1;
72 static int cfg_stddev_tolerance = -1;
78 static struct timeval cfg_tick = { 0, 500*1000 };
93 * - cfg_connlimit_tolerance (--check-connlimit)
94 * - cfg_grouplimit_tolerance (--check-grouplimit)
95 * - cfg_stddev_tolerance (--check-stddev)
137 cs->queued += sizeof(buf); in loud_writecb()
148 cs->received += len; in discard_readcb()
184 --n_echo_conns_open; in echo_eventcb()
193 struct event_base *base = ctx; in echo_listenercb() local
197 bev = bufferevent_socket_new(base, newsock, flags); in echo_listenercb()
201 event_new(base, -1, EV_PERSIST, check_bucket_levels_cb, bev); in echo_listenercb()
229 #define B(x) \ in check_bucket_levels_cb() argument
230 if ((x) > max_bucket_level) \ in check_bucket_levels_cb()
231 max_bucket_level = (x); \ in check_bucket_levels_cb()
232 if ((x) < min_bucket_level) \ in check_bucket_levels_cb()
233 min_bucket_level = (x) in check_bucket_levels_cb()
283 struct event_base *base = NULL; in timer_bias_calculate() local
293 base = event_base_new_with_config(cfg); in timer_bias_calculate()
294 if (!base) in timer_bias_calculate()
297 timer = event_new(base, -1, EV_PERSIST, timer_bias_cb, event_self_cbarg()); in timer_bias_calculate()
303 event_base_dispatch(base); in timer_bias_calculate()
311 if (base) in timer_bias_calculate()
312 event_base_free(base); in timer_bias_calculate()
318 return -1; in timer_bias_calculate()
324 struct event_base *base; in test_ratelimiting() local
338 double expected_total_persec = -1.0, expected_avg_persec = -1.0; in test_ratelimiting()
374 base = event_base_new_with_config(base_cfg); in test_ratelimiting()
376 if (! base) { in test_ratelimiting()
381 listener = evconnlistener_new_bind(base, echo_listenercb, base, in test_ratelimiting()
382 LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, in test_ratelimiting()
410 base, group_bucket_cfg); in test_ratelimiting()
411 expected_total_persec = cfg_grouplimit - (cfg_group_drain / seconds_per_tick); in test_ratelimiting()
432 bevs[i] = bufferevent_socket_new(base, -1, in test_ratelimiting()
442 tv.tv_sec = cfg_duration - 1; in test_ratelimiting()
445 event_base_loopexit(base, &tv); in test_ratelimiting()
448 tv.tv_usec = 100*1000; in test_ratelimiting()
449 ms100_common = event_base_init_common_timeout(base, &tv); in test_ratelimiting()
451 periodic_level_check = event_new(base, -1, EV_PERSIST, check_group_bucket_levels_cb, NULL); in test_ratelimiting()
455 group_drain_event = event_new(base, -1, EV_PERSIST, group_drain_cb, NULL); in test_ratelimiting()
459 event_base_dispatch(base); in test_ratelimiting()
479 event_base_loopexit(base, &tv); in test_ratelimiting()
480 event_base_dispatch(base); in test_ratelimiting()
495 printf("Average max-to-read: %f\n", in test_ratelimiting()
497 printf("Average max-to-write: %f\n", in test_ratelimiting()
521 double diff = expected_total_persec - in test_ratelimiting()
534 double diff = expected_avg_persec - (((double)total_received)/cfg_duration)/cfg_n_connections; in test_ratelimiting()
543 …variance = total_sq_persec/cfg_n_connections - total_persec*total_persec/(cfg_n_connections*cfg_n_… in test_ratelimiting()
552 event_base_free(base); in test_ratelimiting()
562 { "-v", &cfg_verbose, 0, 1 },
563 { "-h", &cfg_help, 0, 1 },
564 { "-n", &cfg_n_connections, 1, 0 },
565 { "-d", &cfg_duration, 1, 0 },
566 { "-c", &cfg_connlimit, 0, 0 },
567 { "-g", &cfg_grouplimit, 0, 0 },
568 { "-G", &cfg_group_drain, -100000, 0 },
569 { "-t", &cfg_tick_msec, 10, 0 },
570 { "--min-share", &cfg_min_share, 0, 0 },
571 { "--check-connlimit", &cfg_connlimit_tolerance, 0, 0 },
572 { "--check-grouplimit", &cfg_grouplimit_tolerance, 0, 0 },
573 { "--check-stddev", &cfg_stddev_tolerance, 0, 0 },
575 { "--iocp", &cfg_enable_iocp, 0, 1 },
577 { NULL, NULL, -1, 0 },
585 if (opt->isbool) { in handle_option()
586 *opt->ptr = 1; in handle_option()
591 return -1; in handle_option()
597 return -1; in handle_option()
599 if (val < opt->min || val > 0x7fffffff) { in handle_option()
600 fprintf(stderr, "Value '%s' is out-of-range'\n", in handle_option()
602 return -1; in handle_option()
604 *opt->ptr = (int)val; in handle_option()
613 "test-ratelim [-v] [-n INT] [-d INT] [-c INT] [-g INT] [-t INT]\n\n" in usage()
614 "Pushes bytes through a number of possibly rate-limited connections, and\n" in usage()
616 " -n INT: Number of connections to open (default: 30)\n" in usage()
617 " -d INT: Duration of the test in seconds (default: 5 sec)\n"); in usage()
619 " -c INT: Connection-rate limit applied to each connection in bytes per second\n" in usage()
621 " -g INT: Group-rate limit applied to sum of all usage in bytes per second\n" in usage()
623 " -G INT: drain INT bytes from the group limit every tick. (default: 0)\n" in usage()
624 " -t INT: Granularity of timing, in milliseconds (default: 1000 msec)\n"); in usage()
665 cfg_tick.tv_sec = cfg_tick_msec / 1000; in main()
666 cfg_tick.tv_usec = (cfg_tick_msec % 1000)*1000; in main()