Re: Interval Timers on Windows
- From: Bernard Chan <cbkihong@xxxxxxxxxxx>
- Date: Sun, 29 Apr 2007 19:43:18 +0800
Martijn Lievaart wrote:
On Sun, 29 Apr 2007 10:47:30 +0100, Brian Wakem wrote:
Surely you would need to time sendPacket() and subtract it from the next
delay?
Surely time spend in sendPacket is negligible om modern machines?
Thanks for your replies.
Actually I have tried a version making similar adjustments to the delay
before, but there was no noticeable improvements (the packet rate is still
highly fluctuating while tending to be slightly < 50Hz in the long term). In
fact the time lag seems to be even more substantial in this version. This is
the exact code of what I tried:
sub sendPacketThread {
my ($t_s, $t_us);
while ($continue) {
($t_s, $t_us) = (time(), ${[gettimeofday()]}[1]);
sendPacket();
my ($t2_s, $t2_us) = (time(), ${[gettimeofday()]}[1]);
my $workTime = ($t2_s - $t_s)*(10**6) + ($t2_us - $t_us);
($t_s, $t_us) = ($t2_s, $t2_us);
select(undef, undef, undef,
($ptime*1000-$workTime)/(10**6));
}
}
This subroutine is what was immediately called from thread->new(). In the
test, both the sender and receiver are on localhost so there should not be
any packet transit issue.
Therefore, I am wondering whether there are any "real" timers accessible on
Windows Perl that gives a more accurate timer. Some fluctuations of delay
in between individual packets is acceptable, but the long-term rate should
be very close to 50Hz or the receiver side will start to drop each packet
on arrival ...
--
Regards,
Bernard Chan
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: Interval Timers on Windows
- From: Martijn Lievaart
- Re: Interval Timers on Windows
- References:
- Interval Timers on Windows
- From: Bernard Chan
- Re: Interval Timers on Windows
- From: Brian Wakem
- Re: Interval Timers on Windows
- From: Martijn Lievaart
- Interval Timers on Windows
- Prev by Date: Re: Weird error after a configuration change
- Next by Date: Re: Interval Timers on Windows
- Previous by thread: Re: Interval Timers on Windows
- Next by thread: Re: Interval Timers on Windows
- Index(es):
Relevant Pages
|