Skip to content

Instantly share code, notes, and snippets.

@galek
Created April 4, 2017 13:50
Show Gist options
  • Save galek/13da74ca4f7b47e6ce5c1b263a78ee05 to your computer and use it in GitHub Desktop.
Save galek/13da74ca4f7b47e6ce5c1b263a78ee05 to your computer and use it in GitHub Desktop.
Clocks
static inline uint64_t cf_getms()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((uint64_t)ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000);
}
static inline uint64_t cf_getus()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((uint64_t)ts.tv_nsec / 1000) + ((uint64_t)ts.tv_sec * 1000000);
}
static inline uint64_t
cf_getns()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)ts.tv_nsec + ((uint64_t)ts.tv_sec * 1000000000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment