Module: BenchmarkMethod::ClassMethods
- Defined in:
- lib/benchmark_method.rb
Instance Method Summary collapse
Instance Method Details
#measure(method) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/benchmark_method.rb', line 14 def measure(method) alias_method "measure_#{method}", method define_method(method) do |*args, &block| method_results = nil results_ms = Benchmark.realtime do method_results = self.send "measure_#{method}", *args, &block end str = "BenchmarkMethod::#{$$}::#{method.to_s}::Total Execution time #{(results_ms * 1000).round(2)}(ms)" defined?(Rails) ? (Rails.logger.error str) : (puts str) #hackish, i guess method_results end end |