Class: BootPolish::NestedBenchmark
- Inherits:
-
Object
- Object
- BootPolish::NestedBenchmark
- Defined in:
- lib/boot_polish/nested_benchmark.rb
Instance Attribute Summary collapse
-
#visitor ⇒ Object
Returns the value of attribute visitor.
Instance Method Summary collapse
-
#initialize(visitor = nil) ⇒ NestedBenchmark
constructor
A new instance of NestedBenchmark.
- #nest(method, &block) ⇒ Object
Constructor Details
#initialize(visitor = nil) ⇒ NestedBenchmark
Returns a new instance of NestedBenchmark.
8 9 10 |
# File 'lib/boot_polish/nested_benchmark.rb', line 8 def initialize(visitor = nil) @visitor = visitor || DefaultRenderer.new end |
Instance Attribute Details
#visitor ⇒ Object
Returns the value of attribute visitor.
6 7 8 |
# File 'lib/boot_polish/nested_benchmark.rb', line 6 def visitor @visitor end |
Instance Method Details
#nest(method, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/boot_polish/nested_benchmark.rb', line 12 def nest method, &block result = nil before_call time_to_run = Benchmark.measure do begin result = yield rescue Exception => e after_call(method, nil, e) raise e end end after_call(method, time_to_run) result end |