class Orbacle::Indexer::StatsRecorder
Public Class Methods
new()
click to toggle source
# File lib/orbacle/indexer.rb, line 11 def initialize @timers = Hash.new(0.0) @counters = Hash.new(0) @values = Hash.new end
Public Instance Methods
all_stats()
click to toggle source
# File lib/orbacle/indexer.rb, line 29 def all_stats @timers.merge(@counters).merge(@values) end
counter(counter_key)
click to toggle source
# File lib/orbacle/indexer.rb, line 37 def counter(counter_key) @counters[counter_key] end
inc(counter_key, by = 1)
click to toggle source
# File lib/orbacle/indexer.rb, line 33 def inc(counter_key, by = 1) @counters[counter_key] += by end
measure(timer) { || ... }
click to toggle source
# File lib/orbacle/indexer.rb, line 17 def measure(timer) started_at = Time.now.to_f process_result = yield finished_at = Time.now.to_f process_result rescue Exception => e finished_at ||= Time.now.to_f raise ensure @timers[timer] += finished_at - started_at end
set_value(key, value)
click to toggle source
# File lib/orbacle/indexer.rb, line 41 def set_value(key, value) @values[key] = value end