diff --git a/test/benchmark-million-timers.c b/test/benchmark-million-timers.c index 3f3fab78..b51c7cdf 100644 --- a/test/benchmark-million-timers.c +++ b/test/benchmark-million-timers.c @@ -25,6 +25,7 @@ #define NUM_TIMERS (1000 * 1000) static int timer_cb_called; +static int close_cb_called; static void timer_cb(uv_timer_t* handle, int status) { @@ -32,6 +33,11 @@ static void timer_cb(uv_timer_t* handle, int status) { } +static void close_cb(uv_handle_t* handle) { + close_cb_called++; +} + + BENCHMARK_IMPL(million_timers) { uv_timer_t* timers; uv_loop_t* loop; @@ -56,7 +62,12 @@ BENCHMARK_IMPL(million_timers) { ASSERT(0 == uv_run(loop)); after = uv_hrtime(); + for (i = 0; i < NUM_TIMERS; i++) + uv_close((uv_handle_t*) (timers + i), close_cb); + + ASSERT(0 == uv_run(loop)); ASSERT(timer_cb_called == NUM_TIMERS); + ASSERT(close_cb_called == NUM_TIMERS); free(timers); LOGF("%.2f seconds\n", (after - before) / 1e9);