class SidekiqLogAnalyser::Statistics

Attributes

collection[R]

Public Class Methods

new(collection) click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 5
def initialize(collection)
  @collection = collection
end

Public Instance Methods

avg() click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 13
def avg
  with_collection do |worker, data|
    data.sum{|metadata| metadata[:duration]}.to_f / data.length
  end
end
timeline() click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 19
def timeline
  with_collection { |worker, data| Timeline.timeline(data) }
end
total() click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 9
def total
  with_collection { |worker, data| data.count }
end

Private Instance Methods

end_collection() click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 35
def end_collection; collection.end_collection; end
start_collection() click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 34
def start_collection; collection.start_collection; end
with_collection() { |worker, data| ... } click to toggle source
# File lib/sidekiq_log_analyser/statistics.rb, line 25
def with_collection
  result = {}
  raw    = end_collection
  raw.each do |worker, data|
    result[worker] = yield(worker, data)
  end
  result
end