From: Jarkko Hietaniemi Date: Sun, 25 Nov 2001 19:11:38 +0000 (+0000) Subject: I don't think trying to bracket the hires time with lores X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=456811e8a3e2c23e7fefd7aba96124b9f0502074;p=p5sagit%2Fp5-mst-13.2.git 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 --- 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