Created
September 15, 2010 20:12
-
-
Save jashkenas/581373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.development? | |
around_filter :perform_profile | |
end | |
# In development mode, optionally perform a RubyProf profile of any request. | |
# Simply pass perform_profile=true in your params. | |
def perform_profile | |
return yield unless params[:perform_profile] | |
require 'ruby-prof' | |
RubyProf.start | |
yield | |
result = RubyProf.stop | |
printer = RubyProf::FlatPrinter.new(result) | |
File.open("#{Rails.root}/tmp/profile.txt", 'w+') do |f| | |
printer.print(f) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment