How do I get a microseconds timestamp in C?
I\'m trying to do:
struct timeval tv;
gettimeofday(&tv,NULL);
return tv.tv_usec;
Bu
timespec_get from C11 returns up to nanoseconds, rounded to the resolution of the implementation.
#include
struct timespec ts;
timespec_get(&ts, TIME_UTC);
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
More details here: https://stackoverflow.com/a/36095407/895245