Class: Ramaze::Dispatcher::ActionProfiler

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

Class Method Summary collapse

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