Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Time::HiRes gettimeofday producing timestamps out of order

by BrowserUk (Pope)
on May 06, 2016 at 13:54 UTC ( #1162354=note: print w/replies, xml ) Need Help??


in reply to Time::HiRes gettimeofday producing timestamps out of order

Which OS are you on?

If you're on Windows, this is a known phenomena of that module on that platform. From the HiRes.XS:

/* If the performance counter delta drifts more than 0.5 seconds from +the * system time then we recalibrate to the system time. This means we +may * move *backwards* in time! */

In your scenario, if when then first timestamp is taken, the clock has drifted by more than half a second, then Time::HiRes 'corrects' its internal counter.

Then, when the second timestamp is taken less that half a second later, the time appears to have run backwards by up to half a second.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Time::HiRes gettimeofday producing timestamps out of order
by 1nickt (Abbot) on May 06, 2016 at 13:57 UTC

    Thanks BUK, that certainly would explain the phenomenon.

    Running on Ubuntu Linux

    $ uname -a Linux vagrant-ubuntu-trusty-64 3.13.0-63-generic #103-Ubuntu SMP Fri A +ug 14 21:42:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

    The way forward always starts with a minimal test.

      See above; I added to my post.

      Perhaps something similar can happen on *nix? Eg. Perhaps the systems clock runs fast, and if NTP updates the time, making the clock step back between timestamps, you get the result you are seeing.

      If that is the cause, you'd expect it to happen at most once per NTP update frequency. (Which should be checkable.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Thanks again. Will look into it. I *thought* ntpd was careful to avoid large changes in updating the clock, but maybe not careful enough.

        Update: Ubuntu docs:

        The ntp daemon ntpd calculates the drift of your system clock and cont +inuously adjusts it, so there are no large corrections that could lea +d to inconsistent logs for instance.
        Hm. Define "large" ...


        The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1162354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2020-01-28 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?