From e2aa39aecfa5efd1fbeeb589220201b529430776 Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Thu, 7 Jun 2012 12:58:11 +0900 Subject: [PATCH] test: change uv_hrtime() test to iterate upto 100 --- test/test-hrtime.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/test/test-hrtime.c b/test/test-hrtime.c index 566e0d2e..43400a46 100644 --- a/test/test-hrtime.c +++ b/test/test-hrtime.c @@ -33,19 +33,22 @@ TEST_IMPL(hrtime) { uint64_t a, b, diff; + int i = 100; + while (i > 0) { + a = uv_hrtime(); + uv_sleep(45); + b = uv_hrtime(); - a = uv_hrtime(); - uv_sleep(100); - b = uv_hrtime(); + diff = b - a; - diff = b - a; + /* printf("i= %d diff = %llu\n", i, (unsigned long long int) diff); */ - printf("diff = %llu\n", (unsigned long long int) diff); - - /* The windows Sleep() function has only a resolution of 10-20 ms. */ - /* Check that the difference between the two hrtime values is somewhat in */ - /* the range we expect it to be. */ - ASSERT(diff > (uint64_t) 80 * NANOSEC / MILLISEC); - ASSERT(diff < (uint64_t) 120 * NANOSEC / MILLISEC); + /* The windows Sleep() function has only a resolution of 10-20 ms. */ + /* Check that the difference between the two hrtime values is somewhat in */ + /* the range we expect it to be. */ + ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); + ASSERT(diff < (uint64_t) 60 * NANOSEC / MILLISEC); + --i; + } return 0; }