Module: BenchmarkWrapper
- Defined in:
- lib/benchmark_wrapper.rb,
lib/benchmark_wrapper/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
Instance Method Details
#wrap_with_benchmark(*meths) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/benchmark_wrapper.rb', line 5 def wrap_with_benchmark(*meths) opts = (meths) out = opts[:out] out_method = opts[:out_method] meths.each do |meth| without_bm, with_bm = wrapper_methods(meth) define_method(with_bm) do |*args, &blk| # obscenely ugly, but Benchmark class seems # to have nothing to avoid this ret_val = nil bm = Benchmark.measure { ret_val = send(without_bm, *args, &blk) } out.send(out_method, bm) ret_val end alias_method without_bm, meth alias_method meth, with_bm end end |