Created
November 14, 2011 20:43
-
-
Save larsacus/1365092 to your computer and use it in GitHub Desktop.
High-Resolution Timer Using Mach Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mach/mach_time.h" //NOT #import | |
mach_timebase_info_data_t mach_info; | |
mach_timebase_info(&mach_info); | |
uint64_t start = mach_absolute_time(); | |
//do stuff to time | |
uint64_t finish = mach_absolute_time() - start; | |
finish *= mach_info.numer; | |
NSLog(@"Time in ms: %f", finish / (mach_info.denom*1000000.0f)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment