summaryrefslogtreecommitdiff
path: root/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp')
-rw-r--r--org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
index cd2eef3..49fd14f 100644
--- a/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
+++ b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
@@ -9,6 +9,9 @@
#include <cassert>
#include <ctime>
+#ifdef WIN32
+ #include <chrono>
+#endif
#define USEC_PER_SEC 1000000ULL
#define NSEC_PER_USEC 1000ULL
@@ -28,10 +31,14 @@ StopWatch::usec_t StopWatch::getTotalElapsedSeconds() const {
}
StopWatch::usec_t StopWatch::now() {
+#ifdef WIN32
+ return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
+#else
struct timespec ts;
assert(!clock_gettime(CLOCK_MONOTONIC, &ts));
return (usec_t) ts.tv_sec * USEC_PER_SEC + (usec_t) ts.tv_nsec / NSEC_PER_USEC;
+#endif
}