I am having a degree of bother with the Time::Hires module, running on Win98;
The output of the following snippet looks something like this:
0
0
0
0
{...repeated several hundred times}
0.0500000715255737
0.0500000715255737
0.0500000715255737
0.0500000715255737
{repeated several hundred - about 6-700 - times}
0.110000014305115
0.110000014305115
0.110000014305115
{you begin to get the picture...}
{etc}
4.94000005722046
4.94000005722046
4.94000005722046
4.94000005722046
5
I understand that the module may not have marvellous performance on windows, I was under the impression that this was in the order of milliseconds being possible, but not much better. My issue is the repeating of the same value (despite $t being refreshed on every loop), at approx. 0.06 second intervals, which is quite a bit worse than milliseconds.
Is this a problem with my code, or have I just misunderstood the appallingness of Windows?
Incidentally, all I want is up to 1/100th of a second, and cross-platformability. Is this too much to ask?
use Time::HiRes qw(time);
$thu = "5.00";
$a="0";
$s=time;
while ($a=="0"){
$t=time;
$f=($t-$s);
print "$f\n";
if ($f==$thu){$a="1";}
}
Any help much appreciated :-)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.