-
-
Save jschoolcraft/115846 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
# config/database.yml | |
profile: | |
development | |
# config/environments/profile.rb | |
config.cache_classes = true | |
config.action_view.cache_template_loading = true | |
config.action_controller.perform_caching = false | |
config.log_level = :info | |
require 'ruby-prof' | |
# config/initializers/profile.rb | |
module ControllerProfiling | |
def self.included(base) | |
base.class_eval do | |
around_filter :profile | |
end | |
end | |
protected | |
def profile | |
result = RubyProf.profile { yield } | |
printer = RubyProf::GraphPrinter.new(result) | |
out = StringIO.new | |
printer.print(out, 0) | |
response.body = out.string | |
response.content_type = "text/plain" | |
end | |
end | |
if Rails.env == 'profile' | |
ApplicationController.send(:include, ControllerProfiling) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment