Skip to content

Instantly share code, notes, and snippets.

@kvnsmth
Created September 26, 2008 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvnsmth/13177 to your computer and use it in GitHub Desktop.
Save kvnsmth/13177 to your computer and use it in GitHub Desktop.
# Q&D Rails Profiling
# Credit Dan Mange: http://www.dcmanges.com/blog/rails-performance-tuning-workflow
require "ruby-prof"
class ApplicationController < ActionController::Base
around_filter :profile
def profile
return yield if params[:profile].nil?
result = RubyProf.profile { yield }
printer = RubyProf::GraphPrinter.new(result)
out = StringIO.new
printer.print(out, 0)
response.body.replace out.string
response.content_type = "text/plain"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment