Skip to content

Instantly share code, notes, and snippets.

@hirokuma
Created August 18, 2017 01:12
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 hirokuma/17bdf87bf3c8c6f29008e74635f9984e to your computer and use it in GitHub Desktop.
Save hirokuma/17bdf87bf3c8c6f29008e74635f9984e to your computer and use it in GitHub Desktop.
clock_gettime()
#include <stdio.h>
#include <time.h>
int main(void)
{
struct timespec ts;
int ret = clock_gettime(CLOCK_REALTIME, &ts);
if (ret == 0) {
printf("tv_sec=%lu, tv_nsec=%ld\n", (unsigned long)ts.tv_sec, ts.tv_nsec);
} else {
perror("clock_gettime");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment