Skip to content

Commit

Permalink
Use evutil_gettimeofday instead of relying on the system gettimeofday.
Browse files Browse the repository at this point in the history
  • Loading branch information
peda-r authored and nmathewson committed May 25, 2011
1 parent 3d768dc commit 0de87fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ run_once(void)
count = 0;
writes = num_writes;
{ int xcount = 0;
gettimeofday(&ts, NULL);
evutil_gettimeofday(&ts, NULL);
do {
event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK);
xcount++;
} while (count != fired);
gettimeofday(&te, NULL);
evutil_gettimeofday(&te, NULL);

if (xcount != count) fprintf(stderr, "Xcount: %d, Rcount: %d\n", xcount, count);
}
Expand Down
4 changes: 2 additions & 2 deletions test/bench_cascade.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ run_once(int num_pipes)
}

/* measurements includes event setup */
gettimeofday(&ts, NULL);
evutil_gettimeofday(&ts, NULL);

/* provide a default timeout for events */
evutil_timerclear(&tv_timeout);
Expand All @@ -116,7 +116,7 @@ run_once(int num_pipes)

event_dispatch();

gettimeofday(&te, NULL);
evutil_gettimeofday(&te, NULL);
evutil_timersub(&te, &ts, &te);

for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
Expand Down
8 changes: 4 additions & 4 deletions test/bench_httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ errorcb(struct bufferevent *b, short what, void *arg)
if (what & BEV_EVENT_EOF) {
++total_n_handled;
total_n_bytes += ri->n_read;
gettimeofday(&now, NULL);
evutil_gettimeofday(&now, NULL);
evutil_timersub(&now, &ri->started, &diff);
evutil_timeradd(&diff, &total_time, &total_time);

Expand Down Expand Up @@ -152,7 +152,7 @@ launch_request(void)

ri = malloc(sizeof(*ri));
ri->n_read = 0;
gettimeofday(&ri->started, NULL);
evutil_gettimeofday(&ri->started, NULL);

b = bufferevent_socket_new(base, sock, BEV_OPT_CLOSE_ON_FREE);

Expand Down Expand Up @@ -184,11 +184,11 @@ main(int argc, char **argv)
perror("launch");
}

gettimeofday(&start, NULL);
evutil_gettimeofday(&start, NULL);

event_base_dispatch(base);

gettimeofday(&end, NULL);
evutil_gettimeofday(&end, NULL);
evutil_timersub(&end, &start, &total);
usec = total_time.tv_sec * 1000000 + total_time.tv_usec;

Expand Down

0 comments on commit 0de87fe

Please sign in to comment.