On Mon, 10 Jul, 2006 at 12:39PM -0400, Dave Robillard spake thus:
james(a)dis-dot-dat.net wrote:
Howdy peeps.
Not really much of a release, so not much fanfare, but in the
interests of sharing effort I give you...
Powernap!
http://dis-dot-dat.net/?item=code/powernap/
If, like me, you need to drive an app from a Python interface,
powernap can help. It's a small extension that switches to the
real-time scheduler and provides two handy sleep-like functions:
nap() naps for a given number of milliseconds, timed with the RTC
rnap() is a "rolling nap" that tries to make the time between calls
the given number of milliseconds. A padding nap, if you will.
It works for me and it might come in handy for someone else.
Nice, this will definitely come in handy for me.
Good! I'm trying to see where I'm writing things that others can make
use of and make them fairly simple to reuse.
Have you done any benchmarking on what kind of timing
precision you can
get?
Nothing particularly concrete. On my amd64 3700 sandiego, with other
apps running (normal desktop kinda stuff), aiming for a time between
sleeps of 310ms using rnap, I get a minimum gap of 308.34 and a
maximum of 312.48, so the range is about 5ms. Standard deviation is
0.67, though and the average is 310.4.
Which is quite good, from Python, I think.
I think there might be a way for it to automatically compensate over
time for tending to be a little over, but 0.4ms probably isn't worth
it.
James
-DR-