class Sidekiq::History::RuntimeStatistic
Public Class Methods
new(redis_statistic, worker, values = nil)
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 4 def initialize(redis_statistic, worker, values = nil) @redis_statistic = redis_statistic @worker = worker @values = values end
Public Instance Methods
average_runtime()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 39 def average_runtime count = values.count return 0.0 if count == 0 total_runtime / count end
last_runtime()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 28 def last_runtime @redis_statistic .for_worker(@worker) .map{ |s| s[:last_runtime] } .compact.last end
max_runtime()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 20 def max_runtime values.max || 0.0 end
min_runtime()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 24 def min_runtime values.min || 0.0 end
total_runtime()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 35 def total_runtime values.inject(:+) || 0.0 end
values_hash()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 10 def values_hash { last: last_runtime, max: max_runtime.round(3), min: min_runtime.round(3), average: average_runtime.round(3), total: total_runtime.round(3) } end
Private Instance Methods
values()
click to toggle source
# File lib/sidekiq/history/statistic/runtime_statistic.rb, line 47 def values @values ||= @redis_statistic .for_worker(@worker) .flat_map{ |s| s[:runtime] } .compact end