/* timing.c ** - Timing functions */ #include #include #include #include #include #ifdef _WIN32 #include #endif #include "timing.h" /* * Returns milliseconds no matter what. */ uint64_t timing_get_time(void) { #ifdef _WIN32 return timeGetTime(); #else struct timeval mtv; gettimeofday(&mtv, NULL); return (uint64_t)(mtv.tv_sec) * 1000 + (uint64_t)(mtv.tv_usec) / 1000; #endif } void timing_sleep(uint64_t sleeptime) { struct timeval sleeper; sleeper.tv_sec = 0; sleeper.tv_usec = sleeptime * 1000; select(1, NULL, NULL, NULL, &sleeper); }