From 2346239887216e2d6d4eb2c34914811203b64bc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20L=C3=A9veill=C3=A9?= <nicolas@uucidl.com>
Date: Sat, 15 Aug 2015 13:47:34 +0200
Subject: [PATCH] Implement h_platform_stopwatch for Windows

We use QueryPerformanceCounter which will return realtime, not user
time.
---
 src/platform_win32.c              | 12 ++++++++++++
 tools/windows/hammer_lib_src_list |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/platform_win32.c b/src/platform_win32.c
index 30af1681..94f80bd8 100644
--- a/src/platform_win32.c
+++ b/src/platform_win32.c
@@ -8,3 +8,15 @@ void h_platform_errx(int err, const char* format, ...) {
   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;
+}
diff --git a/tools/windows/hammer_lib_src_list b/tools/windows/hammer_lib_src_list
index 4c85a43c..87b3b280 100644
--- a/tools/windows/hammer_lib_src_list
+++ b/tools/windows/hammer_lib_src_list
@@ -1,5 +1,6 @@
 platform_win32.c 
-allocator.c 
+allocator.c
+benchmark.c
 bitreader.c 
 bitwriter.c 
 cfgrammar.c 
-- 
GitLab