develooper Front page | perl.perl5.porters | Postings from September 2001

Re: Problem in ext/Time/HiRest/HiRes.t

Thread Previous | Thread Next
From:
Arthur Bergman
Date:
September 4, 2001 02:07
Subject:
Re: Problem in ext/Time/HiRest/HiRes.t
Message ID:
010e01c13521$cd240f90$21000a0a@vogw2kdev

> Arthur Bergman wrote:
> > 
> > Test 14 is the following.
> > 
> > my $t = time();
> > my $tf = Time::HiRes::time();
> > ok 14, (abs($tf - $t) <= 1),
> > "time $t differs from Time::HiRes::time $tf";
> > 
> > When run this multiple (several thousand) times I end up with the
> > following.
> > time 999252194 differs from Time::HiRes::time 999252195.000034
> > 
> > I think the intent would be
> > 
> > ok 14, (int($tf - $t) <= 1),
> > "time $t differs from Time::HiRes::time $tf";
> > 
> > If anyone either opposes this or feels tempted to rewrite the test
> > chime in or I will change it. (this explains a random failing in the
> > Linux smokes)
> 
> ISTM that the test [with the abs] is correct as is.  The test is doing
> what it's meant to do, -- checking that the difference between the
> builtin time() and the hires time() is less than or equal to one second.
> The problem is that it was designed with the idea that both assignments
> would be exactly simultaneously, and they're not.
> 
> With that in mind, try changing the code from:
> 
> my $t = time();
> my $tf = Time::HiRes::time();
> 
> To:
> 
> my $tf = Time::HiRes::time();
> my $t = time();
> 
> And say if you have any different results.  [Leave the abs() as is]
> 

I don't see why the ABS is in there. If we get a negative value something defintly is wrong.

JohnLinderman supplied a patch and I applied it as #11797

Arthur


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About