module SidekiqUniqueJobs::Timing
Handles timing of things
@author Mikael Henriksson <mikael@mhenrixon.com>
Public Instance Methods
clock_stamp()
click to toggle source
Returns a float representation of the current time.
Either from Process or Time
@return [Float]
# File lib/sidekiq_unique_jobs/timing.rb, line 50 def clock_stamp if Process.const_defined?("CLOCK_MONOTONIC") Process.clock_gettime(Process::CLOCK_MONOTONIC) else now_f end end
now_f()
click to toggle source
Returns the current time as float
@see SidekiqUniqueJobs.now_f
@return [Float]
# File lib/sidekiq_unique_jobs/timing.rb, line 39 def now_f SidekiqUniqueJobs.now_f end
time_source()
click to toggle source
Used to get a current representation of time as Integer
@return [Integer]
# File lib/sidekiq_unique_jobs/timing.rb, line 28 def time_source -> { (clock_stamp * 1000).to_i } end
timed() { || ... }
click to toggle source
Used for timing method calls
@return [yield return, Float]
# File lib/sidekiq_unique_jobs/timing.rb, line 16 def timed start_time = time_source.call [yield, time_source.call - start_time] end