I have found a problem with Time::HiRes under Cygwin. Seems that the Time::HiRes::time() function slowly falls behind Perl's core time() function. Running the following for an hour or so illustrates this on my PC, especially when it is under load.
#!/usr/bin/perl use strict; use warnings; use Time::HiRes; while (1) { print("Core : ", scalar localtime(), "\n"); print("HiRes: ", scalar localtime(Time::HiRes::time), "\n\n"); sleep(60); }

Update:I found the source of the problem.

PCs are terrible time keepers. It seems that under heavy load, the clock can continually loose time. On my laptop, I run an NTP client every 5 minutes to compensate for this. Doing so then causes problems with Time::HiRes. Whereas Perl's core time() function picks up on the NTP clock adjustments, Time::HiRes::time() does not.

You can see this by running the script above with sleep(10). Then adjust your PC's clock. You'll see that the 'Core' time picks up the adjustment, but the HiRes time does not.

Whether this constitutes a bug in Time::HiRes or not is a question.


In reply to Time::HiRes::time() Bug on Cygwin by jdhedden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.