diff options
author | Andrew Belt <andrewpbelt@gmail.com> | 2019-08-22 21:56:43 -0400 |
---|---|---|
committer | Andrew Belt <andrewpbelt@gmail.com> | 2019-08-22 21:56:43 -0400 |
commit | 873f6719d08a21f677b013faa9a9d7daf671dd48 (patch) | |
tree | 562884ee4ca77f50759f3882acc277be05508212 | |
parent | 29ba78ab68f417bb6e1d5ae833ee0ed7b60d6faa (diff) |
Use higher precision (but lower accuracy) thread runtime counter on Windows.v1.1.4
-rw-r--r-- | src/system.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/system.cpp b/src/system.cpp index 8175d992..920bae0f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -180,12 +180,18 @@ double getThreadTime() { return 0.0; return info.user_time.seconds + info.user_time.microseconds * 1e-6; #elif defined ARCH_WIN - FILETIME creationTime; - FILETIME exitTime; - FILETIME kernelTime; - FILETIME userTime; - GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime); - return ((((uint64_t) userTime.dwHighDateTime) << 32) + userTime.dwLowDateTime) * 1e-7; + // FILETIME creationTime; + // FILETIME exitTime; + // FILETIME kernelTime; + // FILETIME userTime; + // GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime); + // return ((uint64_t(userTime.dwHighDateTime) << 32) + userTime.dwLowDateTime) * 1e-7; + + uint64_t cycles; + QueryThreadCycleTime(GetCurrentThread(), &cycles); + // HACK Assume that the RDTSC Time-Step Counter instruction is fixed at 2.5GHz. This should only be within a factor of 2 on all PCs. + const double freq = 2.5e9; + return (double) cycles / freq; #endif } |