Class: BME::Suite

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

Defined Under Namespace

Classes: DuplicateBenchmark

Instance Method Summary collapse

Constructor Details

#initialize(iterations) ⇒ Suite

Returns a new instance of Suite.



18
19
20
21
# File 'lib/bme.rb', line 18

def initialize(iterations)
  @iterations = iterations
  @benchmarks = []
end

Instance Method Details

#report(name, options = {}, &block) ⇒ Object



23
24
25
# File 'lib/bme.rb', line 23

def report(name, options = {}, &block)
  add_benchmark(name, options, &block)
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bme.rb', line 27

def run
  adjust_benchmark_names!

  Benchmark.bm do |bench|
    @benchmarks.each do |name, options, block|
      bench.report(name) do 
        (options[:iterations] || @iterations).times { block.call }
      end
    end
  end
end