Fix time measuring on Windows

The demo relied on the build context returning accumulated times in
microseconds. On Windows this was using QueryPerformanceCounter directly
which has a higher resolution, thus returning wrong measured times. We
now report the accumulated times in microseconds on all platforms.
This commit is contained in:
Jakob Botsch Nielsen
2016-01-10 18:43:34 +01:00
parent ac0316e6a8
commit 09080b5272
6 changed files with 12 additions and 13 deletions

View File

@@ -30,13 +30,12 @@ TimeVal getPerfTime()
return count;
}
int getPerfDeltaTimeUsec(const TimeVal start, const TimeVal end)
int getPerfTimeUsec(const TimeVal duration)
{
static __int64 freq = 0;
if (freq == 0)
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
__int64 elapsed = end - start;
return (int)(elapsed*1000000 / freq);
return (int)(duration*1000000 / freq);
}
#else
@@ -52,9 +51,9 @@ TimeVal getPerfTime()
return (TimeVal)now.tv_sec*1000000L + (TimeVal)now.tv_usec;
}
int getPerfDeltaTimeUsec(const TimeVal start, const TimeVal end)
int getPerfTimeUsec(const TimeVal duration)
{
return (int)(end - start);
return (int)duration;
}
#endif