diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-11-21 16:56:13 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-11-21 16:56:13 +0900 |
commit | b1560c7299051a0740ae99189cfbded5bde01a4d (patch) | |
tree | a2f92b729409ba783a5c06f9f48497a4c8004534 /util/benchmark.cc | |
parent | 0ba9cbef683b4db74566e3402ca4ead918a0bdab (diff) | |
download | re2-b1560c7299051a0740ae99189cfbded5bde01a4d.tar.gz re2-b1560c7299051a0740ae99189cfbded5bde01a4d.tar.bz2 re2-b1560c7299051a0740ae99189cfbded5bde01a4d.zip |
Imported Upstream version 20151101upstream/20151101
Change-Id: I3c40e41ceb99e98d4a837077c7342defbe782323
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'util/benchmark.cc')
-rw-r--r-- | util/benchmark.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/util/benchmark.cc b/util/benchmark.cc index 8f72f3c..03dbda4 100644 --- a/util/benchmark.cc +++ b/util/benchmark.cc @@ -25,11 +25,23 @@ void Benchmark::Register() { } static int64 nsec() { -#if defined(__APPLE__) || defined(_WIN32) +#if defined(__APPLE__) struct timeval tv; if(gettimeofday(&tv, 0) < 0) return -1; return (int64)tv.tv_sec*1000*1000*1000 + tv.tv_usec*1000; +#elif defined(_WIN32) + // https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408.aspx + // describes how to query ticks and convert to microseconds. Of course, + // what we want in this case are nanoseconds. Also, note that .QuadPart + // is a signed 64-bit integer, so casting to int64 shouldn't be needed. + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + LARGE_INTEGER ticks; + QueryPerformanceCounter(&ticks); + ticks.QuadPart *= 1000*1000*1000; + ticks.QuadPart /= freq.QuadPart; + return ticks.QuadPart; #else struct timespec tp; if(clock_gettime(CLOCK_REALTIME, &tp) < 0) |