Class: DiffBench::Bm
- Inherits:
-
Object
- Object
- DiffBench::Bm
- Defined in:
- lib/diffbench/bm.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ Bm
constructor
A new instance of Bm.
- #report(label) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Bm
Returns a new instance of Bm.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/diffbench/bm.rb', line 3 def initialize(&block) @measures = {} if block.arity == -1 || block.arity > 0 block.call(self) else instance_eval(&block) end puts Encoder.encode(@measures) end |
Instance Method Details
#report(label) ⇒ Object
14 15 16 17 18 |
# File 'lib/diffbench/bm.rb', line 14 def report(label) @measures[label] = Benchmark.measure do yield end end |