Class: Summon::Benchmark
Instance Method Summary collapse
-
#initialize ⇒ Benchmark
constructor
A new instance of Benchmark.
- #output(to = $stdout) ⇒ Object
- #report(name, &block) ⇒ Object
Constructor Details
#initialize ⇒ Benchmark
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 |