Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Forked from Aissac/gist:115498
Created May 22, 2009 00:29
Show Gist options
  • Save jschoolcraft/115846 to your computer and use it in GitHub Desktop.
Save jschoolcraft/115846 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