summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2014-12-04 13:22:31 +1100
committerskidau <skidau@gmail.com>2014-12-04 13:22:31 +1100
commit7bc78827edcfc4c71ce87e5658fe4fcc01c7e526 (patch)
treed7c9363b6a173e404b6336b21009691350b2acb4 /Source/Core/Common/Timer.cpp
parent4c09f3ab055296b9e74fdac48893fa0c977cb776 (diff)
parent94d9d138d9b8547dc63a705014a5f5b874472613 (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.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
// --------------------------------------------