diff options
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
| -rw-r--r-- | Source/Core/Common/Timer.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 1ba750ae99..025fddeba6 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -32,6 +32,29 @@ u32 Timer::GetTimeMs() #endif } +#ifdef _WIN32 +double GetFreq() +{ + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + return 1000000.0 / double(freq.QuadPart); +} +#endif + +u64 Timer::GetTimeUs() +{ +#ifdef _WIN32 + LARGE_INTEGER time; + static double freq = GetFreq(); + QueryPerformanceCounter(&time); + return u64(double(time.QuadPart) * freq); +#else + struct timeval t; + (void)gettimeofday(&t, nullptr); + return ((u64)(t.tv_sec * 1000000 + t.tv_usec)); +#endif +} + // -------------------------------------------- // Initiate, Start, Stop, and Update the time // -------------------------------------------- |
