summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/timer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'facetracknoir/timer.hpp')
-rw-r--r--facetracknoir/timer.hpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp
index e3fa38de..35ccd4cc 100644
--- a/facetracknoir/timer.hpp
+++ b/facetracknoir/timer.hpp
@@ -1,9 +1,8 @@
#pragma once
-#include <time.h>
+#include <ctime>
#if defined (_WIN32)
# include <windows.h>
-# define CLOCK_MONOTONIC 0
-static inline void clock_gettime(int, struct timespec* ts)
+static inline void opentrack_clock_gettime(int, struct timespec* ts)
{
static LARGE_INTEGER freq;
@@ -20,7 +19,7 @@ static inline void clock_gettime(int, struct timespec* ts)
ts->tv_sec = d.QuadPart / 1000000000L;
ts->tv_nsec = d.QuadPart % 1000000000L;
}
-
+# define clock_gettime opentrack_clock_gettime
#else
# if defined(__MACH__)
# define CLOCK_MONOTONIC 0
@@ -54,8 +53,8 @@ public:
long start() {
struct timespec cur;
(void) clock_gettime(CLOCK_MONOTONIC, &cur);
- int ret = conv(cur);
state = cur;
+ int ret = conv(cur);
return ret;
}
long elapsed() {
@@ -63,4 +62,7 @@ public:
(void) clock_gettime(CLOCK_MONOTONIC, &cur);
return conv(cur);
}
+ long elapsed_ms() {
+ return elapsed() / 1000000L;
+ }
};