in reply to Re^3: Time::HiRes sleep does not always work
in thread Time::HiRes sleep does not always work

If I run your script on my machine (bad) I get:

Counter changes 3579545 times/second QPC: 35752003971 QPC: 35752004170 QPC: 35752004356 QPC: 35752004527 QPC: 35752004695 QPC: 35752004854 QPC: 35752005017 QPC: 35752005169 QPC: 35752005333 QPC: 35752005487 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 GToD: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000 Time: 1219149309.90625000

And here is the output from a "good" machine:

Counter changes 3579545 times/second QPC: 76031246430 QPC: 76031246657 QPC: 76031246790 QPC: 76031247127 QPC: 76031247273 QPC: 76031247479 QPC: 76031247686 QPC: 76031247838 QPC: 76031247972 QPC: 76031248165 GToD: 1219150762.25000000 GToD: 1219150762.25004410 GToD: 1219150762.25007610 GToD: 1219150762.25010900 GToD: 1219150762.25013900 GToD: 1219150762.25017500 GToD: 1219150762.25020500 GToD: 1219150762.25024100 GToD: 1219150762.25027490 GToD: 1219150762.25030590 Time: 1219150762.25033810 Time: 1219150762.25036690 Time: 1219150762.25039600 Time: 1219150762.25042800 Time: 1219150762.25047900 Time: 1219150762.25053190 Time: 1219150762.25058200 Time: 1219150762.25063110 Time: 1219150762.25066710 Time: 1219150762.25069900

Replies are listed 'Best First'.
Re^5: Time::HiRes sleep does not always work
by BrowserUk (Patriarch) on Aug 19, 2008 at 13:28 UTC

    It's not your hardware!

    Your machine is equally capable of high resolution as the "good" machine. That's identified by the first line: Counter changes 3579545 times/second which displays the granularity of the timer, which is the same on both machines.

    That means if they are both using the same version of Time::HiRes, then they should be giving the same results. The first thing I would try is re-installing the module. From CPAN if you are compiler-capable. From a PPM otherwise. And, if your paranoid like me, you'll blow away the existing files first:

    <yourperl>/lib/Time::HiRes.pm <yourperl>/lib/auto/Time/HiRes/*

    If the problem persists after that, something very hookey is going on with your install.


    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      The "Good" machine that I tried above wasn't the original one that my testing was done on because that colleague wasn't at work yesterday but I got to run the test today and the results from that test are below

      Counter changes 14318180 times/second QPC: 4512760987142 QPC: 4512760987382 QPC: 4512760987508 QPC: 4512760987617 QPC: 4512760987726 QPC: 4512760987835 QPC: 4512760987939 QPC: 4512760988043 QPC: 4512760988148 QPC: 4512760988253 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 GToD: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000 Time: 1219217113.05580000

      I'm going to try and reinstall my Time::HiRes anyway to to make sure the problem isn't there

        Very strange. The hardware is capable of high resolution as evidenced by the QPC: output.

        And Time::HiRes has the code to utilise that capability, but from the evidence of the gettimeofday() & time() output, that code is not being exercised.

        It's like something is caching the value, or some set of build options was used when the code was compiled to cause it to bypass the code? Did you say this was an AS built Perl?


        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".
        In the absence of evidence, opinion is indistinguishable from prejudice.