Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Make the gethostbyname benchmark more precise
  • Loading branch information
piscisaureus committed May 22, 2012
1 parent a478847 commit 25316a3
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions test/benchmark-ares.c
Expand Up @@ -41,16 +41,16 @@ static int argument;
static int64_t start_time;
static int64_t end_time;

/* callback method. may issue another call */
static void aresbynamecallback( void *arg,
int status,
int timeouts,
struct hostent *hostent) {
ares_callbacks++;
if (status != 0) {
ares_errors++;
}

/* callback method. */
static void aresbynamecallback(void *arg,
int status,
int timeouts,
struct hostent *hostent) {
ares_callbacks++;
if (status != 0) {
ares_errors++;
}
}


Expand Down Expand Up @@ -89,30 +89,29 @@ BENCHMARK_IMPL(gethostbyname) {
ares_callbacks = 0;
ares_errors = 0;

uv_update_time(loop);
start_time = uv_now(loop);
start_time = uv_hrtime();

prep_tcploopback();

for (ares_start = 0; ares_start < NUM_CALLS_TO_START; ares_start++) {
ares_gethostbyname(channel,
"echos.srv",
AF_INET,
&aresbynamecallback,
&argument);
"echos.srv",
AF_INET,
&aresbynamecallback,
&argument);
}

uv_run(loop);

uv_ares_destroy(loop, channel);

end_time = uv_now(loop);
end_time = uv_hrtime();

if (ares_errors > 0) {
printf("There were %d failures\n", ares_errors);
}
LOGF("ares_gethostbyname: %.0f req/s\n",
1000.0 * ares_callbacks / (double)(end_time - start_time));
1e9 * ares_callbacks / (double)(end_time - start_time));

return 0;
}

0 comments on commit 25316a3

Please sign in to comment.