Class: Rack::Profiler
- Inherits:
-
Object
- Object
- Rack::Profiler
- Defined in:
- lib/rack/contrib/profiler.rb
Overview
Set the profile=process_time query parameter to download a calltree profile of the request.
Pass the :printer option to pick a different result format.
Constant Summary collapse
- MODES =
%w( process_time wall_time cpu_time allocations memory gc_runs gc_time )
- DEFAULT_PRINTER =
RubyProf::CallTreePrinter
- DEFAULT_CONTENT_TYPE =
'application/octet-stream'
- PRINTER_CONTENT_TYPE =
{ RubyProf::FlatPrinter => 'text/plain', RubyProf::GraphPrinter => 'text/plain', RubyProf::GraphHtmlPrinter => 'text/html' }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Profiler
constructor
Accepts a :printer => [:call_tree|:graph_html|:graph|:flat] option defaulting to :call_tree.
Constructor Details
#initialize(app, options = {}) ⇒ Profiler
Accepts a :printer => [:call_tree|:graph_html|:graph|:flat] option defaulting to :call_tree.
30 31 32 33 34 |
# File 'lib/rack/contrib/profiler.rb', line 30 def initialize(app, = {}) @app = app @printer = parse_printer([:printer]) @times = ([:times] || 1).to_i end |
Instance Method Details
#call(env) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rack/contrib/profiler.rb', line 36 def call(env) if mode = profiling?(env) profile(env, mode) else @app.call(env) end end |