diff options
author | Howard Chu <hyc@symas.com> | 2016-04-06 03:41:52 +0100 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2016-04-06 03:41:52 +0100 |
commit | aaaf9e2e6d81a2f300d724f1daab3d7aa1f798bf (patch) | |
tree | 071f869e4d005a0190657a8a6d30299b6c001f41 | |
parent | Merge pull request #780 (diff) | |
download | monero-aaaf9e2e6d81a2f300d724f1daab3d7aa1f798bf.tar.xz |
Fix get_tick_count() on Windows
GetTickCount used in 52056dcfc480a126e06afaf209b1772b6aa77fb3
only has ~10-16ms resolution. Use higher rez timer to get 1ms rez.
-rw-r--r-- | contrib/epee/include/misc_os_dependent.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h index 2abca0446..806d3e83e 100644 --- a/contrib/epee/include/misc_os_dependent.h +++ b/contrib/epee/include/misc_os_dependent.h @@ -53,11 +53,13 @@ namespace misc_utils #if defined(_MSC_VER) return ::GetTickCount64(); #elif defined(WIN32) -# if defined(WIN64) - return GetTickCount64(); -# else - return GetTickCount(); -# endif + static LARGE_INTEGER pcfreq = {0}; + LARGE_INTEGER ticks; + if (!pcfreq.QuadPart) + QueryPerformanceFrequency(&pcfreq); + QueryPerformanceCounter(&ticks); + ticks.QuadPart *= 1000; /* we want msec */ + return ticks.QuadPart / pcfreq.QuadPart; #elif defined(__MACH__) clock_serv_t cclock; mach_timespec_t mts; |