Skip to content

Instantly share code, notes, and snippets.

@Aissac
Created May 21, 2009 14:55
Show Gist options
  • Save Aissac/115498 to your computer and use it in GitHub Desktop.
Save Aissac/115498 to your computer and use it in GitHub Desktop.
# 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