Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Unexpected Timing spikes using Time::HiRes

by hossman (Prior)
on Jan 19, 2010 at 08:03 UTC ( [id://818131]=note: print w/replies, xml ) Need Help??


in reply to Unexpected Timing spikes using Time::HiRes

Have you considered checking hte return value of usleep (or sleep) to see how many actual seconds the method slept for, and then compare that with the delta from Time::HiRes::gettimeofday

I suspect that Time::HiRes::gettimeofday is in fact returning the accurate time for your system at the moment you call it, but you are seeing the larger then expected deltas because other things are happening on your system (besides the sleep) in between your calls -- Perl garbage collection, other processes on the same machine, etc....

My first suggestion was to try something like...

time perl -MTime::HiRes -le 'print ((Time::HiRes::gettimeofday())[1]) + for (1..500)'

...where you sanity check the numbers printed out looking for any really odd jumps, and Compare the "real" time reported by your system with the delta between the first/last times printed so see if they concur.

But the compilation/interpreter startup is significant enough to provide missleading info at such a small level of granularity.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://818131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found