summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.cpp
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-11-19 19:57:12 +0100
committerdegasus <wickmarkus@web.de>2014-12-03 00:50:41 +0100
commit94d9d138d9b8547dc63a705014a5f5b874472613 (patch)
tree6356a56fcb4a5962691540695781989899a0bc05 /Source/Core/Common/Timer.cpp
parente40f129fdd844d59250aa60e36e3b96a0099d957 (diff)
Common: Add a built-in profiler
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
-rw-r--r--Source/Core/Common/Timer.cpp23
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
// --------------------------------------------