Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I looked at the Benchmark modules and it seems the bugs for it are in the perl5 category -- I guess that means it's part of 'Core'?
Anyway, that's why I'm reporting this here.
This is using the Inst_Version 1.13 distributed with 5.16.3 -- I.E. this may already be fixed, not easily testable at this point.
But using a call to Benchmark::timestr:
my $time_str = Benchmark::timestr($diff, 'all', '20.9F');
note, at the top, I have:
So, it should be giving microsecond accuracy. Drilling down
/* A time value that is accurate to the nearest
So the cpu seconds only appear to be accurage to 100's of a second, but clock_info on my system shows:
(My cpu clock is set to 1000Hz:
so that would make it logical that cpu times might only be accurate to 1ms, but it doesn't appear to have used the 20.9F format for the realtime either.
I was a bit surprised by the output -- I expected a space-separated string of 5 numbers (for real, parent process and children processes). I must have not been clear on the documentation about the extra verbiage being included.
Side question: Is there anyway just to get back the array of 5 numbers so no conversions are necessary -- especially since the conversion thing doesn't seem to work right? (thought 20.9F would give me double precision (64-bits?)... thought I'd at least get back more than centisecs...
Note clock_info does *seem* to return time in nanoseconds...but haven't investigated those sources (not that I need such accuracy, but was trying, simply, to store the full accuracy of what Benchmark had stored internally -- thus my sideQ about a way to get values w/o conversions or breaking into the Benchmark object).
At the very least, if that accuracy is the best that is possible, that might be mentioned in the manpage, though it's pretty clearly not using the precision for the real-time clock.
Linda Walsh wrote:
The module is distributed only with the Perl core; this is indeed the
As the name suggests, and as the documentation explicitly says,
As you note, higher-resolution CPU timers are available on some hosts
The documentation is not clear that the format string passed to
On Wed Jun 08 16:16:16 2016, email@example.com wrote:
It's doubly unclear that the "FORMAT" only applies to the cpu times -- for which anything greater than 5.2f appears useless. I.e. the 1 place where > %5.2f could be seen, (wall clock) is is apparent that the FORMAT is ignored, vs. being used on the cpu-times where the :hireswallclock makes no difference. (i.e. - Irony?).