Class: Rack::RubyProf

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-prof/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RubyProf

Returns a new instance of RubyProf.



3
4
5
# File 'lib/ruby-prof/rack.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/ruby-prof/rack.rb', line 7

def call(env)
  ::RubyProf.start
  result = @app.call(env)
  data = ::RubyProf.stop

  print(data)
  result
end


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby-prof/rack.rb', line 16

def print
  printers = {::RubyProf::FlatPrinter => 'c:/temp/profile.txt',
              ::RubyProf::GraphHtmlPrinter => 'c:/temp/profile.html'}

  printers.each do |printer_klass, file_name|
    printer = printer_klass.new(result)
      ::File.open(file_name, 'wb') do |file|
      printer.print(file, :min_percent => 0.00000001 )
    end
  end
end