diff options
| author | skidau <skidau@gmail.com> | 2014-12-04 13:22:31 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2014-12-04 13:22:31 +1100 |
| commit | 7bc78827edcfc4c71ce87e5658fe4fcc01c7e526 (patch) | |
| tree | d7c9363b6a173e404b6336b21009691350b2acb4 /Source/Core/Common/Timer.cpp | |
| parent | 4c09f3ab055296b9e74fdac48893fa0c977cb776 (diff) | |
| parent | 94d9d138d9b8547dc63a705014a5f5b874472613 (diff) | |
Merge pull request #1574 from degasus/profiler
Common: Add a built-in profiler
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 // -------------------------------------------- |
