Click here to get back home

accuracy of Time::HiRes

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
accuracy of Time::HiRes John 06-27-2008
Posted by John on June 27, 2008, 4:38 pm
Please log in for more thread options
Hi

use Time::HiRes qw (gettimeofday);
my ($secs,$milliseconds)=gettimeofday();
my $trans="$secs$milliseconds"; # 10 digits and 6 digits

Sometimes the length of $trans is 16 but sometimes it is 15.
Shouldn't it be 16 always?

Regards
John






Posted by Anonymous coward on June 27, 2008, 5:14 pm
Please log in for more thread options
On Fri, 27 Jun 2008 21:38:39 +0100, John wrote:

> Hi
>
> use Time::HiRes qw (gettimeofday);
> my ($secs,$milliseconds)=gettimeofday(); my $trans="$secs$milliseconds";
> # 10 digits and 6 digits
>
> Sometimes the length of $trans is 16 but sometimes it is 15. Shouldn't
> it be 16 always?
>
> Regards
> John

The length of microseconds (not milliseconds) will be 5 digits one out of
ten times, because it's value is less than 100000 microseconds. In one
out of a hundred times it will be 4 digits, etc. If you rely on the
length of it, you should probably use sprintf.

Regards,

Leon Timmermans

Posted by John on June 28, 2008, 1:54 am
Please log in for more thread options

> On Fri, 27 Jun 2008 21:38:39 +0100, John wrote:
>
>> Hi
>>
>> use Time::HiRes qw (gettimeofday);
>> my ($secs,$milliseconds)=gettimeofday(); my $trans="$secs$milliseconds";
>> # 10 digits and 6 digits
>>
>> Sometimes the length of $trans is 16 but sometimes it is 15. Shouldn't
>> it be 16 always?
>>
>> Regards
>> John
>
> The length of microseconds (not milliseconds) will be 5 digits one out of
> ten times, because it's value is less than 100000 microseconds. In one
> out of a hundred times it will be 4 digits, etc. If you rely on the
> length of it, you should probably use sprintf.
>
> Regards,
>
> Leon Timmermans

Hi

Of course, I see that now. I need the length to create a unique number of
standard length. sprintf will do that.
Many thanks.

Regards
John




Similar ThreadsPosted
Time::HiRes hell... July 1, 2008, 12:36 pm
Time::HiRes < 1.91 and glibc 2.4 incompatibility April 12, 2008, 8:46 am
Time::HiRes module and timing a command... November 16, 2004, 10:54 am
problems with Time::HiRes on some SLES systems September 28, 2006, 1:08 am
Time::HiRes usleep on windows strange behaviour...please please help!! November 29, 2005, 11:37 pm
number accuracy December 13, 2006, 12:53 pm
GMT time to local time, according to timezone and summer/winter time. May 15, 2005, 10:45 pm
Calculating time of employee session from the log date/time stampusing perl May 24, 2005, 5:55 pm
How do I convert TIME into Cookie and last-modified-time format? October 1, 2004, 3:05 pm
Compare UNIX file time with time in a variable November 23, 2006, 2:39 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap