Make the gethostbyname benchmark more precise
This commit is contained in:
parent
a478847f74
commit
25316a3f92
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user