Class: Ramaze::Dispatcher::ActionProfiler

Inherits:
Action show all
Defined in:
lib/ramaze/contrib/profiling.rb

Class Method Summary collapse

Methods inherited from Action

#after_process, #before_process, #binding, #common_aspect, create, current, #engine, #extended_path, #full_path, #instance, #method=, #name, #params=, #relaxed_hash, #render, #stack, stack, #to_hash, #to_s, #valid_rest?

Methods inherited from Struct

fill, #values_at

Class Method Details

.call(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ramaze/contrib/profiling.rb', line 6

def self.call(path)
  if RubyProf.running?
    super
  else
    result = RubyProf.profile { super }
    output = StringIO.new
    printer = RubyProf::FlatPrinter.new(result)
    options = {
      :min_percent => Contrib::Profiling.trait[:min_percent],
      :print_file => false
    }
    printer.print(output, options)
    output.string.split("\n").each do |line|
      Log.info(line)
    end
  end
end