Make the gethostbyname benchmark more precise

This commit is contained in:
Bert Belder 2012-05-22 02:49:17 +02:00
parent a478847f74
commit 25316a3f92

View File

@ -41,7 +41,8 @@ static int argument;
static int64_t start_time;
static int64_t end_time;
/* callback method. may issue another call */
/* callback method. */
static void aresbynamecallback(void *arg,
int status,
int timeouts,
@ -50,7 +51,6 @@ static void aresbynamecallback( void *arg,
if (status != 0) {
ares_errors++;
}
}
@ -89,8 +89,7 @@ BENCHMARK_IMPL(gethostbyname) {
ares_callbacks = 0;
ares_errors = 0;
uv_update_time(loop);
start_time = uv_now(loop);
start_time = uv_hrtime();
prep_tcploopback();
@ -106,13 +105,13 @@ BENCHMARK_IMPL(gethostbyname) {
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;
}