Module: SidekiqUniqueJobs::Timing
- Included in:
- Lock, Locksmith, OnConflict::Reject, OnConflict::Strategy, Orphans::RubyReaper, Redis::Entity
- Defined in:
- lib/sidekiq_unique_jobs/timing.rb
Overview
Handles timing of things
Class Method Summary collapse
-
.clock_stamp ⇒ Float
Returns a float representation of the current time.
-
.now_f ⇒ Float
Returns the current time as float.
-
.time_source ⇒ Integer
Used to get a current representation of time as Integer.
-
.timed ⇒ yield return, Float
Used for timing method calls.
Class Method Details
.clock_stamp ⇒ Float
Returns a float representation of the current time.
Either from Process or Time
50 51 52 53 54 55 56 |
# 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 ⇒ Float
Returns the current time as float
39 40 41 |
# File 'lib/sidekiq_unique_jobs/timing.rb', line 39 def now_f SidekiqUniqueJobs.now_f end |
.time_source ⇒ Integer
Used to get a current representation of time as Integer
28 29 30 |
# File 'lib/sidekiq_unique_jobs/timing.rb', line 28 def time_source -> { (clock_stamp * 1000).to_i } end |
.timed ⇒ yield return, Float
Used for timing method calls
16 17 18 19 20 |
# File 'lib/sidekiq_unique_jobs/timing.rb', line 16 def timed start_time = time_source.call [yield, time_source.call - start_time] end |