Class: RBM::Benchmarker
- Inherits:
-
Object
- Object
- RBM::Benchmarker
- Defined in:
- lib/rbm/benchmarker.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :times => 1 }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(fragments, options) ⇒ Benchmarker
constructor
A new instance of Benchmarker.
- #run ⇒ Object
Constructor Details
#initialize(fragments, options) ⇒ Benchmarker
Returns a new instance of Benchmarker.
11 12 13 14 15 16 |
# File 'lib/rbm/benchmarker.rb', line 11 def initialize(fragments, ) @options = DEFAULT_OPTIONS.merge() compile_prerun([:prerun]) @fragments = fragments.map { |name, fragment| [name, compile_fragment(fragment, [:prerun], name)] } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/rbm/benchmarker.rb', line 9 def @options end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rbm/benchmarker.rb', line 18 def run width = @fragments.map { |name, method| name.size }.max Benchmark.bm(width) do |bm| @fragments.each do |name, method| bm.report(name) do # TODO: wrap errors from fragment execution [:times].times { send(method) } end end end end |