Class: RBM::Benchmarker

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :times => 1
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fragments, options = {}) ⇒ Benchmarker

Returns a new instance of Benchmarker.



11
12
13
14
# File 'lib/rbm/benchmarker.rb', line 11

def initialize(fragments, options = {})
  @fragments = fragments
  @options = self.class::DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#fragmentsObject (readonly)

Returns the value of attribute fragments.



9
10
11
# File 'lib/rbm/benchmarker.rb', line 9

def fragments
  @fragments
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/rbm/benchmarker.rb', line 9

def options
  @options
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
# File 'lib/rbm/benchmarker.rb', line 16

def run
  Benchmark.bmbm do |bm|
    fragments.each do |fragment|
      fragment.run(bm, options[:times], options[:init], options[:cleanup])
    end
  end
end