Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Milliseconds



On Jan 16, 2007, at 5:22 AM, Mike Kluev wrote:

On Mon, 15 Jan 2007 10:46:37 George Warner <email@hidden> wrote:

Just for the record UpTime (and CFAbsoluteTimeGetCurrent and
mach_absolute_time) is still the lowest-overhead and highest precision clock
on PPC or Intel. (IIRC UpTime & CFAbsoluteTimeGetCurrent both call directly
thru to mach_absolute_time now.)


#import <mach/mach_time.h>

    uint64_t t0 = mach_absolute_time();

    // do your timed stuff here!

    uint64_t t1 = mach_absolute_time();

    // compute the delta
    uint64_t t = t1 - t0;

// this is the timebase info
mach_timebase_info_data_t info;
mach_timebase_info(&info);
double nano = 1e-9 * ( (double) info.numer) / ((double) info.denom);

For the record, how aggressively may we cache the result of mach_timebase_info? Is it guaranteed to be a constant for a program run or could it change with e.g. the change of processor speed?

That's the best reason to use gettimeofday -- it keeps you from having to worry about this. gettimeofday is also very highly optimized.


-Eric

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Milliseconds (From: Mike Kluev <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.