diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-06-14 18:32:30 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-06-14 18:32:30 +0200 |
commit | 3b78a8e2b2050430135c275c429e30201552fa8c (patch) | |
tree | 4094a51adf624479d62fce8d872781cc1be67f8d | |
parent | b1b442b17a626974c8840dd6a3912e078f00883e (diff) |
timer: switch to nanosecond precision
-rw-r--r-- | facetracknoir/timer.hpp | 8 |
1 files changed, 4 insertions, 4 deletions
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); |