Re: (RS) hi-res clock function
Re: (RS) hi-res clock function
- Subject: Re: (RS) hi-res clock function
- From: Jeff Koftinoff <email@hidden>
- Date: Wed, 25 Oct 2006 06:01:46 -0700
On 25-Oct-06, at 5:07 AM, Alastair Houghton wrote:
On Oct 25, 2006, at 1:00 PM, Alastair Houghton wrote:
On Oct 25, 2006, at 12:48 PM, Roland Silver wrote:
Is there a function like clock() that returns time (since some
origin) directly to a finer resolution than clock does?
Take a look at the man page for gettimeofday(2).
Just to add to that, you might find that it doesn't have a higher
resolution, in which case you might need to use something system
dependent. (The PowerPC timebase register, for instance). It
might be worth checking the Mach APIs to see if there's something
that lets you do that kind of thing in a non-system-specific manner
(you'll need to download xnu and look in the osfmk/man folder for
the docs).
Of course, I'm sure someone else will point out some other time API
any minute now that fits the bill :-)
In addition, keep in mind that all time functions are only as
accurate as the kernel scheduler anyways - For instance if you call
gettimeofday or get the ppc tb reg you may get a very accurate count
- But then before you even get to use the time value your application
may get pre-empted by some higher priority function. When it is
scheduled back again in may be 5 or 10 or more milliseconds later
than your accurate value specifies.
So be sure to make your algorithms allow for this...
Jeff Koftinoff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden