Created
April 28, 2018 14:31
-
-
Save zhangyangjing/5ee32a99a5f44c7509a0c1b2fa5412bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <time.h> | |
static long currentTimeInNs() { | |
struct timespec res; | |
clock_gettime(CLOCK_MONOTONIC, &res); | |
return (res.tv_sec * 1e9) + res.tv_nsec; | |
} | |
static long currentTimeInMs(void) { | |
struct timespec res; | |
clock_gettime(CLOCK_REALTIME, &res); | |
return 1000 * res.tv_sec + res.tv_nsec / 1e6; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment