Module: Stats::Times
- Included in:
- Stats
- Defined in:
- lib/stats/times.rb
Instance Method Summary collapse
-
#get_times(name) ⇒ Object
Returns the timing data for the stat with the specified name.
-
#time(name, &block) ⇒ Object
Adds a new time for the stat with the specified name.
Instance Method Details
#get_times(name) ⇒ Object
Returns the timing data for the stat with the specified name.
4 5 6 |
# File 'lib/stats/times.rb', line 4 def get_times(name) TimingStat.new(Stats.redis.lrange(name, 0, -1).map { |time| time.to_f }) end |
#time(name, &block) ⇒ Object
Adds a new time for the stat with the specified name.
9 10 11 12 13 |
# File 'lib/stats/times.rb', line 9 def time(name, &block) raise ArgumentError.new("Block required to time.") unless block realtime = Benchmark.realtime { block.call } Stats.redis.rpush(name, realtime) end |