aboutsummaryrefslogtreecommitdiff
path: root/test/bench.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/bench.c')
-rw-r--r--test/bench.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/test/bench.c b/test/bench.c
index 3a6886d..f2af4d3 100644
--- a/test/bench.c
+++ b/test/bench.c
@@ -70,6 +70,7 @@ static int writes, failures;
static evutil_socket_t *pipes;
static int num_pipes, num_active, num_writes;
static struct event *events;
+static struct event_base *base;
static void
@@ -105,11 +106,11 @@ run_once(void)
for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
if (event_initialized(&events[i]))
event_del(&events[i]);
- event_set(&events[i], cp[0], EV_READ | EV_PERSIST, read_cb, (void *)(ev_intptr_t) i);
+ event_assign(&events[i], base, cp[0], EV_READ | EV_PERSIST, read_cb, (void *)(ev_intptr_t) i);
event_add(&events[i], NULL);
}
- event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK);
+ event_base_loop(base, EVLOOP_ONCE | EVLOOP_NONBLOCK);
fired = 0;
space = num_pipes / num_active;
@@ -123,7 +124,7 @@ run_once(void)
int xcount = 0;
evutil_gettimeofday(&ts, NULL);
do {
- event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK);
+ event_base_loop(base, EVLOOP_ONCE | EVLOOP_NONBLOCK);
xcount++;
} while (count != fired);
evutil_gettimeofday(&te, NULL);
@@ -147,6 +148,9 @@ main(int argc, char **argv)
int i, c;
struct timeval *tv;
evutil_socket_t *cp;
+ const char **methods;
+ const char *method = NULL;
+ struct event_config *cfg = NULL;
#ifdef _WIN32
WSADATA WSAData;
@@ -155,7 +159,7 @@ main(int argc, char **argv)
num_pipes = 100;
num_active = 1;
num_writes = num_pipes;
- while ((c = getopt(argc, argv, "n:a:w:")) != -1) {
+ while ((c = getopt(argc, argv, "n:a:w:m:l")) != -1) {
switch (c) {
case 'n':
num_pipes = atoi(optarg);
@@ -166,6 +170,16 @@ main(int argc, char **argv)
case 'w':
num_writes = atoi(optarg);
break;
+ case 'm':
+ method = optarg;
+ break;
+ case 'l':
+ methods = event_get_supported_methods();
+ fprintf(stdout, "Using Libevent %s. Available methods are:\n",
+ event_get_version());
+ for (i = 0; methods[i] != NULL; ++i)
+ printf(" %s\n", methods[i]);
+ exit(0);
default:
fprintf(stderr, "Illegal argument \"%c\"\n", c);
exit(1);
@@ -187,7 +201,16 @@ main(int argc, char **argv)
exit(1);
}
- event_init();
+ if (method != NULL) {
+ cfg = event_config_new();
+ methods = event_get_supported_methods();
+ for (i = 0; methods[i] != NULL; ++i)
+ if (strcmp(methods[i], method))
+ event_config_avoid_method(cfg, methods[i]);
+ base = event_base_new_with_config(cfg);
+ event_config_free(cfg);
+ } else
+ base = event_base_new();
for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
#ifdef USE_PIPES