lib/timeouter/timer.rb in timeouter-0.1.2.16873 vs lib/timeouter/timer.rb in timeouter-0.1.2.38793
- old
+ new
@@ -11,15 +11,15 @@
@timeout = [timeout, 0].max
@eclass = eclass || Timeouter::TimeoutError
@message = message || 'execution expired'
- @started_at = Time.now
+ @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
# elapsed time from creation
def elapsed
- Time.now - @started_at
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - @started_at
end
# time left to be exhausted or nil if timeout was 0
def left
(@timeout > 0) ? [@timeout - elapsed, 0].max : nil