Skip to content

Instantly share code, notes, and snippets.

@teamon
Created June 5, 2013 14:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save teamon/5714502 to your computer and use it in GitHub Desktop.
Save teamon/5714502 to your computer and use it in GitHub Desktop.
Profile rails controller with ruby-prof
# gem "ruby-prof"
around_filter :profiler
def profiler(&block)
data = RubyProf::Profile.profile(&block)
filepath = Rails.root.join("tmp", "profiler.html")
File.open(filepath, "w") do |f|
RubyProf::CallStackPrinter.new(data).print(f)
end
Rails.logger.debug "Profiler results saved to #{filepath}"
system "open #{filepath}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment