|Syntactic Confectionery Delight|
Unexpected Timing spikes using Time::HiResby desemondo (Hermit)
|on Jan 19, 2010 at 06:19 UTC||Need Help??|
desemondo has asked for the wisdom of the Perl Monks concerning the following question:
I am in need of accurate time measurement down to 0.1ms - Generally Time::HiRes does seem to do pretty well, but (using the below code) sometimes gets spikes of 15.625ms.
In reading the module notes, it says Do not expect usleep() to be exact down to one microsecond which I'm perfectly fine with, that makes sense. but these spikes, 15.625ms (most commonly), are way above 50-100 microseconds... which was the kind of precision I was expecting/hoping for.
Is my code actually measuring the accuracy of Time::HiRes or are these spikes due to something else?
If the code is fine, how might I be able to better determine what the current time is with accuracy down to 0.1ms? (To clarify, I don't specifically need to sleep for an exact amount of time, I need a means of calculating what the current time is down to 0.1ms accuracy at certain events.)
Incidentally, on my last test, only 63 samples out of 20,000 were unexpected, which is ok, but I'd like to do better than that if possible...
Thanks in advance
Update: I'm using ActivePerl 5.8.8 and 5.10.1