class Rack::Lineprof
Constants
- CONTEXT
- CRITICAL
- NOMINAL
- WARNING
Attributes
app[R]
options[R]
Public Class Methods
new(app, options = {})
click to toggle source
# File lib/rack/lineprof.rb, line 18 def initialize app, options = {} @app, @options = app, options end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/lineprof.rb, line 22 def call env request = Rack::Request.new env matcher = request.params['lineprof'] || options[:profile] logger = options[:logger] || ::Logger.new(STDOUT) return @app.call env unless matcher response = nil profile = lineprof(%r{#{matcher}}) { response = @app.call env } logger.debug Term::ANSIColor.blue("\n[Rack::Lineprof] #{'=' * 63}") + "\n\n" + format_profile(profile) + "\n" response end
format_profile(profile)
click to toggle source
# File lib/rack/lineprof.rb, line 38 def format_profile profile sources = profile.map do |filename, samples| Source.new filename, samples, options end sources.map(&:format).compact.join "\n" end