summaryrefslogtreecommitdiff
path: root/util/benchmark.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/benchmark.cc')
-rw-r--r--util/benchmark.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/benchmark.cc b/util/benchmark.cc
index c3aad7e..8f72f3c 100644
--- a/util/benchmark.cc
+++ b/util/benchmark.cc
@@ -25,10 +25,17 @@ void Benchmark::Register() {
}
static int64 nsec() {
+#if defined(__APPLE__) || defined(_WIN32)
struct timeval tv;
if(gettimeofday(&tv, 0) < 0)
return -1;
return (int64)tv.tv_sec*1000*1000*1000 + tv.tv_usec*1000;
+#else
+ struct timespec tp;
+ if(clock_gettime(CLOCK_REALTIME, &tp) < 0)
+ return -1;
+ return (int64)tp.tv_sec*1000*1000*1000 + tp.tv_nsec;
+#endif
}
static int64 bytes;