-#if USE_CLOCK_GETTIME
-
-// Since the monotonic clock will provide us with the time since the
-// computer started, the number of seconds since that time could easily
-// become so large that it cannot be accurately stored in a float (even
-// with as little two days uptime), therefore we need to start from a more
-// recent reference (when the program starts). Of course this isn't much
-// of an issue if scalar is a double-precision number.
+ scalar ticks() const
+ {
+ struct timespec ts;
+ int result = clock_gettime(CLOCK_MONOTONIC, &ts);
+ ASSERT(result == 0 && "monotonic clock not available");
+
+ return reference_ +
+ (scalar(ts.tv_sec - start_.tv_sec) +
+ scalar(ts.tv_nsec - start_.tv_nsec) *
+ SCALAR(0.000000001)) * scale_;
+ }