static uint64_t GetMonoTimeMillis() { timespec ts; ASSERT(clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0); return ts.tv_sec * 1'000 + ts.tv_nsec / 1'000'000; } static uint64_t GetMonoTimeMicros() { timespec ts; ASSERT(clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0); return ts.tv_sec * 1'000'000 + ts.tv_nsec / 1'000; } static uint64_t GetMonoTimeNanos() { timespec ts; ASSERT(clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0); return ts.tv_sec * 1'000'000'000 + ts.tv_nsec; } static wall_clock_time GetWallTime() { timespec ts; ASSERT(clock_gettime(CLOCK_REALTIME, &ts) == 0); time_t t = (time_t)ts.tv_sec; tm local_tm; localtime_r(&t, &local_tm); wall_clock_time ret{}; ret.Year = (uint32_t)(local_tm.tm_year + 1900); ret.Month = (uint32_t)(local_tm.tm_mon + 1); ret.Day = (uint32_t)local_tm.tm_mday; ret.Hour = (uint32_t)local_tm.tm_hour; ret.Minute = (uint32_t)local_tm.tm_min; ret.Second = (uint32_t)local_tm.tm_sec; return ret; } static void Sleep(uint64_t millis) { usleep(millis * 1000L); }