Class: Maze::Timers
- Inherits:
-
Object
- Object
- Maze::Timers
- Defined in:
- lib/maze/timers.rb
Overview
Stores a collection of timers
Instance Method Summary collapse
- #add(name) ⇒ Object
- #get(name) ⇒ Object
-
#initialize ⇒ Timers
constructor
A new instance of Timers.
- #report ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ Timers
Returns a new instance of Timers.
26 27 28 |
# File 'lib/maze/timers.rb', line 26 def initialize @timers = {} end |
Instance Method Details
#add(name) ⇒ Object
30 31 32 33 34 |
# File 'lib/maze/timers.rb', line 30 def add(name) timer = Timer.new @timers[name] = timer timer end |
#get(name) ⇒ Object
36 37 38 |
# File 'lib/maze/timers.rb', line 36 def get(name) @timers[name] end |
#report ⇒ Object
44 45 46 47 48 49 |
# File 'lib/maze/timers.rb', line 44 def report $logger.info 'Timer totals:' @timers.sort.each do |name, timer| $logger.info " #{name}: #{timer.total}" end end |
#size ⇒ Object
40 41 42 |
# File 'lib/maze/timers.rb', line 40 def size @timers.size end |