From 3b78a8e2b2050430135c275c429e30201552fa8c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Jun 2014 18:32:30 +0200 Subject: timer: switch to nanosecond precision --- facetracknoir/timer.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index 623836db..e3fa38de 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -43,22 +43,22 @@ static inline void clock_gettime(int, struct timespec* ts) class Timer { private: struct timespec state; - int conv(const struct timespec& cur) + long conv(const struct timespec& cur) { - return (cur.tv_sec - state.tv_sec) * 1000L + (cur.tv_nsec - state.tv_nsec) / 1000000L; + return (cur.tv_sec - state.tv_sec) * 1000000000L + (cur.tv_nsec - state.tv_nsec); } public: Timer() { start(); } - int start() { + long start() { struct timespec cur; (void) clock_gettime(CLOCK_MONOTONIC, &cur); int ret = conv(cur); state = cur; return ret; } - int elapsed() { + long elapsed() { struct timespec cur; (void) clock_gettime(CLOCK_MONOTONIC, &cur); return conv(cur); -- cgit v1.2.3