From 456811e8a3e2c23e7fefd7aba96124b9f0502074 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sun, 25 Nov 2001 19:11:38 +0000 Subject: [PATCH] I don't think trying to bracket the hires time with lores times is going to be portable enough: Cygwin seems to be capable of getting hires ones rather consistently lower than the lores ones. So let's try average difference instead. p4raw-id: //depot/perl@13266 --- ext/Time/HiRes/HiRes.t | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ext/Time/HiRes/HiRes.t b/ext/Time/HiRes/HiRes.t index bee3257..ad0dcc3 100644 --- a/ext/Time/HiRes/HiRes.t +++ b/ext/Time/HiRes/HiRes.t @@ -133,16 +133,15 @@ else { if (!$have_time) { skip 14 } else { - my ($t1, $tf, $t2); - for my $i (1 .. 20) { - $t1 = time(); - $tf = Time::HiRes::time(); - $t2 = 1 + time(); - last if (($t2 - $t1) <= 1) && $t1 <= $tf; + my ($s, $n); + for my $i (1 .. 100) { + $s += Time::HiRes::time() - time(); + $n++; } - ok 14, (($t1 <= $tf) && ($tf <= $t2)), - "Time::HiRes::time $tf not bracketed by [$t1, $t2]"; - + # $s should be, at worst, equal to $n + # (time() may be rounding down, up, or closest) + ok 14, abs($s) / $n <= 1.0, "Time::HiRes::time() not close to time()"; + print "# s = $s, n = $n, s/n = ", $s/$n, "\n"; } unless (defined &Time::HiRes::gettimeofday -- 2.7.4