Class: Maze::Timers

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/timers.rb

Overview

Stores a collection of timers

Instance Method Summary collapse

Constructor Details

#initializeTimers

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

#reportObject



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

#sizeObject



40
41
42
# File 'lib/maze/timers.rb', line 40

def size
  @timers.size
end