Accurate timing in C code
- From: Tony Houghton <this.address.is.fake@xxxxxxxxxxx>
- Date: Sat, 2 Sep 2006 21:19:41 +0100
What can I use for accurately measuring elapsed time in C code? I'm
looking for round about millisecond accuracy. I've written some code to
wait for vsyncs using OpenGL, but while glXGetRefreshRateSGI reports a
consistent 59Hz, measuring the time between two syncs with gettimeofday
results in a period corresponding to anything up to 88Hz, although it
does seem to usually give 59.8802.
I tried clock(), but that doesn't return anything useful.
Most video players seem to use /dev/rtc but I can't find useful
documentation about it. The kernel docs suggest that the way it's used
is that you program it with the frequency you want it to generate
interrupts (requiring root access for >64Hz, so that's a problem for a
start). Wouldn't that affect the whole machine? What if two applications
want to use it at the same time, at different frequencies? And the clock
can be disturbed by its being kept in sync with external sources etc.
--
The address in the Reply-To is genuine and should not be edited.
See <http://www.realh.co.uk/contact.html> for more reliable contact addresses.
.
- Follow-Ups:
- Re: Accurate timing in C code
- From: Robert Billing
- Re: Accurate timing in C code
- From: Martin Gregorie
- Re: Accurate timing in C code
- From: Alex Butcher
- Re: Accurate timing in C code
- From: Bruce Stephens
- Re: Accurate timing in C code
- Prev by Date: Re: Mail server under attack
- Next by Date: Re: Accurate timing in C code
- Previous by thread: Re: Migrating to a new drive.
- Next by thread: Re: Accurate timing in C code
- Index(es):
Relevant Pages
|