Module: Nitro::BenchmarkHelper

Defined in:
lib/nitro/helper/benchmark.rb

Overview

This helper adds benchmarking support in your Controllers. Useful for fine tuning and optimizing your actions.

Instance Method Summary collapse

Instance Method Details

#benchmark(message = 'Benchmarking') ⇒ Object

Log real time spent on a task.

Example

benchmark “Doing an operation” { operation }



16
17
18
19
# File 'lib/nitro/helper/benchmark.rb', line 16

def benchmark(message = 'Benchmarking')
  real = Benchmark.realtime { yield }
  Logger.info "#{message}: time = #{'%.5f' % real} ms."
end