Re: Filling in a struct timespec with the current date?
Re: Filling in a struct timespec with the current date?
- Subject: Re: Filling in a struct timespec with the current date?
- From: Esteban Bodigami <email@hidden>
- Date: Wed, 29 Jul 2009 09:55:30 -0600
// Calculate the duration.
elapsed = end - start;
// Convert to nanoseconds.
// Have to do some pointer fun because AbsoluteToNanoseconds
// works in terms of UnsignedWide, which is a structure rather
// than a proper 64-bit integer.
elapsedNano = AbsoluteToNanoseconds( *(AbsoluteTime *) &elapsed );
return * (uint64_t *) &elapsedNano;
10−9 seconds and 10−8 seconds (1 ns and 10 ns)
10
3 seconds (a
kilosecond)
1.440 ks to 1.500 ks = my "kilosecond"
3.600 kiloseconds = one hour
4.440 kiloseconds = 74 minutes (audio cd)
10
4 seconds = 1 myriad of seconds; 1 0000 s
/*
benchmark using the clock of your choice what the computer "sees" as 10^3 seconds and what one "sees" on the computer in... minutes.seconds (&SoD); everything else is margin of error (which should be recorded to enhance the software). 4.44 ks is more than 1 hour and 3.60 ks is exactly 1 "hour"
*/
OK, the best documentation I've found for this is at
http://developer.apple.com/qa/qa2004/qa1398.html
and I whipped up a quick test program to ensure I knew what I was doing with it. Now my question concerns accuracy; I know that mach_absolute_time() resolves to one nanosecond, but what is the accuracy? Is there a way to tell what the accuracy is from the mach_timebase_info struct? E.g., the greatest common denominator between numer and denom is the accuracy of the clock in nanoseconds?
This won't affect my current code, but I'd like to stick it into my own documentation so whenever I reuse this code I know what I'm getting in to.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden