Fix get_tick_count() on Windows
GetTickCount used in 52056dcfc4
only has ~10-16ms resolution. Use higher rez timer to get 1ms rez.
This commit is contained in:
parent
e7c8a32a28
commit
aaaf9e2e6d
1 changed files with 7 additions and 5 deletions
|
@ -53,11 +53,13 @@ namespace misc_utils
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
return ::GetTickCount64();
|
return ::GetTickCount64();
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
# if defined(WIN64)
|
static LARGE_INTEGER pcfreq = {0};
|
||||||
return GetTickCount64();
|
LARGE_INTEGER ticks;
|
||||||
# else
|
if (!pcfreq.QuadPart)
|
||||||
return GetTickCount();
|
QueryPerformanceFrequency(&pcfreq);
|
||||||
# endif
|
QueryPerformanceCounter(&ticks);
|
||||||
|
ticks.QuadPart *= 1000; /* we want msec */
|
||||||
|
return ticks.QuadPart / pcfreq.QuadPart;
|
||||||
#elif defined(__MACH__)
|
#elif defined(__MACH__)
|
||||||
clock_serv_t cclock;
|
clock_serv_t cclock;
|
||||||
mach_timespec_t mts;
|
mach_timespec_t mts;
|
||||||
|
|
Loading…
Reference in a new issue