My version of
Time::HiRes doesn't have
setitimer, but I get fairly precise results with
alarm:
#!/usr/bin/perl -w
use strict;
use Time::HiRes qw (alarm time);
$SIG{ALRM} = sub { printf "%16.5f\n",time; alarm(0.5); };
alarm(0.5);
while(1)
{
select(undef,undef,undef,1);
}
produces
1069651689.38722
1069651689.88720
1069651690.38720
1069651690.88721
1069651691.38721
If you can't alarms at precise times, you can try to make up for it by printing packets/second, which should be the same even if the alarms are off by a little bit. You may also find that using 1-second intervals works better, since that's the traditional interface provided by alarm, but I'm not sure.
This is on RedHat 7.2, kernel 2.4.20, perl 5.6.1, Time::HiRes 1.20.
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.