Index: tools/timer/SysTimer_windows.cpp |
diff --git a/tools/timer/SysTimer_windows.cpp b/tools/timer/SysTimer_windows.cpp |
index 8e45b4a68ed3ccabab401ec27f6138e490e56d22..8f53a44d7c103a7c755ecd56ca2e48010ec65d7d 100644 |
--- a/tools/timer/SysTimer_windows.cpp |
+++ b/tools/timer/SysTimer_windows.cpp |
@@ -38,16 +38,24 @@ double SysTimer::endCpu() { |
// at the CPU's maximum rate, even while power management clocks the CPU up and down. |
// That's great, because it makes measuring wall time super simple. |
+static double ticks_to_ms(unsigned _int64 ticks) { |
+ // This seems to, weirdly, give the CPU frequency in kHz. That's exactly what we want! |
+ LARGE_INTEGER freq_khz; |
+ QueryPerformanceFrequency(&freq_khz); |
+ |
+ return static_cast<double>(ticks) / static_cast<double>(freq_khz.QuadPart); |
+} |
+ |
void SysTimer::startWall() { |
fStartWall = __rdtsc(); |
} |
double SysTimer::endWall() { |
unsigned __int64 end = __rdtsc(); |
+ return ticks_to_ms(end - fStartWall); |
+} |
- // This seems to, weirdly, give the CPU frequency in kHz. That's exactly what we want! |
- LARGE_INTEGER freq_khz; |
- QueryPerformanceFrequency(&freq_khz); |
- |
- return static_cast<double>(end - fStartWall) / static_cast<double>(freq_khz.QuadPart); |
+double GetTimeMs() { |
+ static const unsigned __int64 launchTime = __rdtsc(); |
+ return ticks_to_ms(__rdtsc() - launchTime); |
} |