Skip to content

Instantly share code, notes, and snippets.

@sebmck
Created May 19, 2013 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmck/5607450 to your computer and use it in GitHub Desktop.
Save sebmck/5607450 to your computer and use it in GitHub Desktop.
uint64_t uv__hrtime(void) {
mach_timebase_info_data_t info;
if (mach_timebase_info(&info) != KERN_SUCCESS)
abort();
return mach_absolute_time() * info.numer / info.denom;
}
uint64_t uv__hrtime(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment