Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: change uv_hrtime() test to iterate upto 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Shigeki Ohtsu authored and bnoordhuis committed Jun 7, 2012
1 parent b47af98 commit e2aa39a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions test/test-hrtime.c
Expand Up @@ -33,19 +33,22 @@

TEST_IMPL(hrtime) {
uint64_t a, b, diff;

a = uv_hrtime();
uv_sleep(100);
b = uv_hrtime();

diff = b - a;

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);
int i = 100;
while (i > 0) {
a = uv_hrtime();
uv_sleep(45);
b = uv_hrtime();

diff = b - a;

/* printf("i= %d diff = %llu\n", i, (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) 25 * NANOSEC / MILLISEC);
ASSERT(diff < (uint64_t) 60 * NANOSEC / MILLISEC);
--i;
}
return 0;
}

0 comments on commit e2aa39a

Please sign in to comment.