From 25316a3f921ace8f62a84974f976235fb0cd5976 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 22 May 2012 02:49:17 +0200 Subject: [PATCH] Make the gethostbyname benchmark more precise --- test/benchmark-ares.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/test/benchmark-ares.c b/test/benchmark-ares.c index 0c09e175..27084fae 100644 --- a/test/benchmark-ares.c +++ b/test/benchmark-ares.c @@ -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++; + } } @@ -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; }