Skip to content

Instantly share code, notes, and snippets.

@VincentSit
Forked from brysonian/nanos.cpp
Created May 9, 2016 17:01
Show Gist options
  • Save VincentSit/492bb6ebcf17cdf82ebb6b7f23a4228a to your computer and use it in GitHub Desktop.
Save VincentSit/492bb6ebcf17cdf82ebb6b7f23a4228a to your computer and use it in GitHub Desktop.
get a nanosecond accurate counter for ios and os x
uint64_t nanos() {
static mach_timebase_info_data_t info;
mach_timebase_info(&info);
uint64_t now = mach_absolute_time();
now *= info.numer;
now /= info.denom;
return now;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment