Sha256: 32c6da337f8f639e2505c477c602f556216464996d891f84fb30316e060fbf48

Contents?: true

Size: 485 Bytes

Versions: 5

Compression:

Stored size: 485 Bytes

Contents

require 'benchmark'

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

module BenchmarkHelper

  # Log real time spent on a task. 
  # 
  # === Example
  # 
  # benchmark "Doing an operation" { operation }
  
  def benchmark(message = 'Benchmarking')
    real = Benchmark.realtime { yield }
    Logger.info "#{message}: time = #{'%.5f' % real} ms."
  end

end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.27.0 lib/nitro/helper/benchmark.rb
nitro-0.28.0 lib/nitro/helper/benchmark.rb
nitro-0.29.0 lib/nitro/helper/benchmark.rb
nitro-0.30.0 lib/nitro/helper/benchmark.rb
nitro-0.31.0 lib/nitro/helper/benchmark.rb