Implement h_platform_stopwatch for Windows

We use QueryPerformanceCounter which will return realtime, not user
time.
This commit is contained in:
Nicolas Léveillé 2015-08-15 13:47:34 +02:00
parent 739f5d6d5c
commit 2346239887
2 changed files with 14 additions and 1 deletions

View file

@ -8,3 +8,15 @@ void h_platform_errx(int err, const char* format, ...) {
ExitProcess(err); ExitProcess(err);
} }
void h_platform_stopwatch_reset(struct HStopWatch* stopwatch) {
QueryPerformanceFrequency(&stopwatch->qpf);
QueryPerformanceCounter(&stopwatch->start);
}
/* return difference between last reset point and now */
int64_t h_platform_stopwatch_ns(struct HStopWatch* stopwatch) {
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return 1000000000 * (now.QuadPart - stopwatch->start.QuadPart) / stopwatch->qpf.QuadPart;
}

View file

@ -1,5 +1,6 @@
platform_win32.c platform_win32.c
allocator.c allocator.c
benchmark.c
bitreader.c bitreader.c
bitwriter.c bitwriter.c
cfgrammar.c cfgrammar.c