in reply to Time::HiRes::time() Bug on Cygwin

jdhedden,
You do not say how far behind. Reading the docs:

NOTE 1: This higher resolution timer can return values
either less or more than the core time(), depending on
whether your platform rounds the higher resolution timer
values up, down, or to the nearest second to get the core
time(), but naturally the difference should be never more
than half a second.

It would not be unrealistic to see the times off due to rounding issues. Additionally, you do not specify which OS you are running Cygwin on. It is my understanding the granularity of sleep may be determined by the kernel. I was not able to reproduce your problem using the following code beyond the expected discrepency:
#!/usr/bin/perl use strict; use warnings; use Time::HiRes 'usleep'; while (1) { print "Core : ", CORE::time, "\n"; print "HiRes: ", Time::HiRes::time, "\n\n"; usleep (60_000_000); }
Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Time::HiRes::time() Bug on Cygwin
by jdhedden (Deacon) on Apr 04, 2004 at 15:41 UTC
    It is not a rounding problem. The error gets increasingly longer at a rate of several seconds per hour.

    This is on Windows 98. I don't see how it could be a granularity issue. The problem is that the error keeps accumulating.

    Using your code, I was able to preproduce the problem:

    Core : 1081092725 HiRes: 1081092725.097 Core : 1081092785 HiRes: 1081092785.098 Core : 1081092849 HiRes: 1081092845.099 Core : 1081092908 HiRes: 1081092905.1 Core : 1081092968 HiRes: 1081092965.105 Core : 1081093029 HiRes: 1081093025.106 Core : 1081093088 HiRes: 1081093085.162
    Here it shows a discrete jump of about 4 seconds. No idea why.