Class: Summon::Benchmark

Inherits:
Object show all
Defined in:
lib/summon/benchmark.rb

Instance Method Summary collapse

Constructor Details

#initializeBenchmark

Returns a new instance of Benchmark.



6
7
8
# File 'lib/summon/benchmark.rb', line 6

def initialize
  @timings = []
end

Instance Method Details

#output(to = $stdout) ⇒ Object



17
18
19
20
# File 'lib/summon/benchmark.rb', line 17

def output(to = $stdout)
  to.printf("%20s  %s\n", "","real time")
  to.puts(@timings.map {|t| t.format("%-20n: %r")})
end

#report(name, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/summon/benchmark.rb', line 9

def report(name, &block)
  result = nil
  @timings << ::Benchmark.measure(name) do
    result = block.call
  end
  result
end