Skip to content

Instantly share code, notes, and snippets.

@larsacus
Created November 14, 2011 20:43
Show Gist options
  • Save larsacus/1365092 to your computer and use it in GitHub Desktop.
Save larsacus/1365092 to your computer and use it in GitHub Desktop.
High-Resolution Timer Using Mach Time
#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