Perl: the Markov chain saw | |
PerlMonks |
Re^2: Anything better than 'times' ?by gone2015 (Deacon) |
on Sep 17, 2008 at 18:18 UTC ( [id://712087]=note: print w/replies, xml ) | Need Help?? |
I had tried Time::HiRes::clock(), but that gives the same resolution as times. So I thought that was a dead end. However, I went back and read again. There are Time::HiRes::clock_gettime($which) and Time::HiRes::getres($which). Where the $which is the name of a POSIX high resolution timer. I confess I had assumed that this was wall-clock. The POSIX timer CLOCK_REALTIME claims a resolution of 1E-9 on my machine. Hurrah :-) However, that is wall-clock. Boo :-( The Time::HiRes hints that there may be other timers... so, I went digging in the POSIX documentation. I found CLOCK_PROCESS_CPUTIME_ID, which does what the name suggests, and also claims a resolution of 1E-9 on my machine. Hurrah ! Conclusion, yes: turns out that Time::HiRes is the answer -- thank you. To know that, however, you need to know that:
is the trick -- which I note in case it's of use to anyone like me who knew nothing of it until today.
In Section
Seekers of Perl Wisdom
|
|