/usr/lib/ruby/vendor_ruby/metriks/time_tracker.rb is in ruby-metriks 0.9.9.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | module Metriks
class TimeTracker
def initialize(interval)
@interval = interval
@next_time = Time.now.to_f
end
def sleep
sleep_time = next_time - Time.now.to_f
if sleep_time > 0
Kernel.sleep(sleep_time)
end
end
def now_floored
time = Time.now.to_i
time - (time % @interval)
end
def next_time
now = Time.now.to_f
@next_time = now if @next_time <= now
@next_time += @interval - (@next_time % @interval)
end
end
end
|