Skip to content

Commit 61619eb

Browse files
authored
Merge pull request #786 from lygstate/windows-h
Move include Windows.h into Cpp
2 parents c60d8cf + 3ad2f9d commit 61619eb

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

sbe-benchmarks/src/main/cpp/benchlet-main.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,23 @@ int main(int argc, char **argv)
1919
{
2020
BenchmarkRunner::run();
2121
return 0;
22-
}
22+
}
23+
24+
#ifdef _WIN32
25+
#include <Windows.h>
26+
uint64_t BenchmarkRunner::currentTimestamp(void)
27+
{
28+
static LARGE_INTEGER freq;
29+
static int first = 1;
30+
LARGE_INTEGER counter;
31+
32+
::QueryPerformanceCounter(&counter);
33+
if (1 == first)
34+
{
35+
::QueryPerformanceFrequency(&freq);
36+
first = 0;
37+
}
38+
return (1000000000 * counter.QuadPart)/freq.QuadPart;
39+
}
40+
41+
#endif

sbe-benchmarks/src/main/cpp/benchlet.h

+1-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#elif defined(__linux__)
2929
# include <time.h>
3030
#elif defined(WIN32) || defined(_WIN32)
31-
# include <windows.h>
3231
#else
3332
# error "Must define Darwin or __linux__ or WIN32"
3433
#endif /* platform includes */
@@ -213,21 +212,7 @@ class BenchmarkRunner
213212
return end_timestamp - start_timestamp;
214213
};
215214
#elif defined(WIN32) || defined(_WIN32)
216-
static uint64_t currentTimestamp(void)
217-
{
218-
static LARGE_INTEGER freq;
219-
static int first = 1;
220-
LARGE_INTEGER counter;
221-
222-
::QueryPerformanceCounter(&counter);
223-
if (1 == first)
224-
{
225-
::QueryPerformanceFrequency(&freq);
226-
first = 0;
227-
}
228-
return (1000000000 * counter.QuadPart)/freq.QuadPart;
229-
}
230-
215+
static uint64_t currentTimestamp(void);
231216
static uint64_t elapsedNanoseconds(uint64_t start_timestamp, uint64_t end_timestamp)
232217
{
233218
return end_timestamp - start_timestamp;

0 commit comments

Comments
 (0)