diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-25 19:11:38 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-25 19:11:38 +0000 |
commit | 456811e8a3e2c23e7fefd7aba96124b9f0502074 (patch) | |
tree | 77a85e8cfc27fa2714e459d74acb660b1178277d /ext/Time | |
parent | 4eb872f6fa3f99a8a9d7e5f5b2ed3cfdca62d33d (diff) | |
download | perl-456811e8a3e2c23e7fefd7aba96124b9f0502074.tar.gz |
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
Diffstat (limited to 'ext/Time')
-rw-r--r-- | ext/Time/HiRes/HiRes.t | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ext/Time/HiRes/HiRes.t b/ext/Time/HiRes/HiRes.t index bee325742e..ad0dcc32ba 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 |