Download this file
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <stdint.h> #include <sys/time.h> static uint64_t clock_millis() { struct timeval tv; static uint64_t last = 0; int result = gettimeofday(&tv, NULL); if (result != 0) { printf("Failed to read clock\n"); return last; } last = (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec / 1000; return last; }