-
-
Save VincentSit/492bb6ebcf17cdf82ebb6b7f23a4228a to your computer and use it in GitHub Desktop.
get a nanosecond accurate counter for ios and os x
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
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