in reply to Re^2: making something happen in real time
in thread making something happen in real time
But I need better resolution than one second.
Oh, sorry, didn't listen carefully. Then use Time::HiRes, which is a core module on newer perls:
or the gettimeoftheday function from the same module, or (on linux)perl -we 'use Time::HiRes "time"; print time, "\n";'
but 156 instead of 78 on solaris, and 116 (untested) instead of 78 on freebsd, (Update:) 96 instead of 78 on linux-x86_64.perl -we 'defined(syscall 78, ($d = pack "x100"), 0) or die "panic: ge +ttimeofday failed $!"; ($s, $u) = unpack "l!l!", $d; printf "%d.%06d\ +n", $s, $u;'
Update:
My point is that you have to ask for the time before every sleep. I don't see your code, so you might already be doing that. Of course, if you spawn an external process for querying the time, then that's slow, so don't do that.Before every tick, get the current time, and wait whatever time is left till the next tick.That's essentially what I'm already doing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: making something happen in real time
by bcrowell2 (Friar) on Nov 06, 2005 at 22:03 UTC | |
|
Re^4: making something happen in real time
by bcrowell2 (Friar) on Nov 07, 2005 at 02:38 UTC |