Skip Menu |

This queue is for tickets about the Time-HiRes CPAN distribution.

Report information
The Basics
Id: 87915
Status: rejected
Priority: 0/
Queue: Time-HiRes

People
Owner: Nobody in particular
Requestors: jserink2013 [...] hushmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bug in the usec output
Date: Sat, 17 Aug 2013 23:33:07 +0800
To: bug-time-hires [...] rt.cpan.org
From: jserink2013 [...] hushmail.com
Hi All: My system:jserinki7 jserink # uname -aLinux jserinki7 3.8.13-gentoo #1 SMP PREEMPT Sun May 19 19:59:35 SGT 2013 x86_64 Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz GenuineIntel GNU/Linux Time::HiRes version:* perl-core/Time-HiRes Latest version available: 1.972.500 Latest version installed: 1.972.500 Size of files: 86 kB Homepage: http://search.cpan.org/dist/Time-HiRes/ Description: Perl Time::HiRes. High resolution alarm, sleep, gettimeofday, interval timers License: || ( Artistic GPL-1 GPL-2 GPL-3 ) When comparing to the normal time functions, when the usec value from:my($secs, $usec) = gettimeofday(); crosses zero, it outputs garbage. See below:20130817-23:18:17 1376752697.92020130817-23:18:17 1376752697.10114720130817-23:18:17 1376752697.20143220130817-23:18:17 1376752697.30170820130817-23:18:17 1376752697.40197220130817-23:18:17 1376752697.50223720130817-23:18:17 1376752697.60250420130817-23:18:17 1376752697.70277620130817-23:18:17 1376752697.80302120130817-23:18:17 1376752697.90325120130817-23:18:18 1376752698.3529
You don't show what code you're using to generate that output. It appears that the code is printing "$secs.$usec", with sleeps of 1/10 second between calls to gettimeofday. (You're also printing a formatted date and time-of-day, and a newline, the latter in the wrong place.) The output is sensible for such code. It appears that you are getting confused by the $usec values having fewer than six decimal digits. You're trying to use $usec directly as a string of fractional decimal digits to append to decimal $secs, but that's not what $usec is. It's the *number of microseconds* since the top of the second, and so needs to be padded with zeroes if it's to be used as a string of fractional digits. Try sprintf("%d.%06d", $secs, $usec). -zefram