Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/benchrb.rb
Instance Method Summary collapse
-
#bench(*args, &block) ⇒ Object
Convenience method for printing benchmarks inline with code.
Instance Method Details
#bench(*args, &block) ⇒ Object
Convenience method for printing benchmarks inline with code.
bench 100, "sleep 0.01"
bench{ sleep 0.01 }
Interactive mode with the current binding:
bench binding
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/benchrb.rb', line 479 def bench *args, &block count = 1 binding = nil rb_str = nil args.each do |val| case val when String then rb_str = val when Integer then count = val when Binding then binding = val end end puts BenchRb.run(rb_str, :count => count, :binding => binding, &block).inspect puts "Caller: #{caller[0]}" end |