Module: Benchmarked
- Defined in:
- lib/benchmarked.rb,
lib/benchmarked/version.rb,
lib/benchmarked/class_methods.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
'0.1.0'
Class Attribute Summary collapse
-
.notifier ⇒ Object
writeonly
Sets the attribute notifier.
Class Method Summary collapse
- .benchmark_and_notify(obj, method_name, args) ⇒ Object
- .clean_configuration ⇒ Object
- .configure {|_self| ... } ⇒ Object
Class Attribute Details
.notifier=(value) ⇒ Object (writeonly)
Sets the attribute notifier
7 8 9 |
# File 'lib/benchmarked.rb', line 7 def notifier=(value) @notifier = value end |
Class Method Details
.benchmark_and_notify(obj, method_name, args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/benchmarked.rb', line 13 def benchmark_and_notify(obj, method_name, args) result = nil if @notifier.nil? result = yield else measurement = Benchmark.measure { result = yield } @notifier.benchmark_taken(measurement, obj, method_name, args, result) end result end |
.clean_configuration ⇒ Object
26 27 28 |
# File 'lib/benchmarked.rb', line 26 def clean_configuration @notifier = nil end |
.configure {|_self| ... } ⇒ Object
9 10 11 |
# File 'lib/benchmarked.rb', line 9 def configure yield(self) end |