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

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

Thread Previous
From:
John P. Linderman
Date:
August 31, 2001 04:26
Subject:
Re: Problem in ext/Time/HiRest/HiRes.t
Message ID:
200108311126.HAA42697@raptor.research.att.com
Arthur replied,
> 01-08-31 12.27, skrev John P. Linderman på jpl@research.att.com följande:
> 
> > 
> > I think it's risky to assume that your process won't get swapped
> > out for a second or two between the time() and the Time::HiRes::time().
> > Maybe something like
> > 
> > my $t1 = time();
> > my $tf = Time::HiRes::time();
> > my $t2 = 1 + time();
> > 
> > and confirm that ($t1 <= $tf) && ($tf <= $t2)
> > 
> > One might even try a few iterations, ($t2 - $t1) is greater than 1.
> > --jpl
> 
> Patches welcome :)
> 
> But I agree, infact I think the entire test is a little bogus.
> 
> Why not just int($tf - $t) <= 2 ?
> 
> -- 
> Arthur

Because that puts an upper limit (although a not unreasonable one)
on the delay between the execution of the time() and the 
Time::HiRes::time() calls.  If you're testing Perl on heavily
loaded Altair :-), maybe the OS will swap you out for 3 seconds
between the two calls.  My ultra-paranoid test will
tolerate that.  -- jpl


Thread Previous


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