Profile Rails requests on a live app
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib Stringify content length Jun 11, 2009
MIT-LICENSE Rename license file Jan 29, 2009


Action Profiler

`gem install ruby-prof` then add ?profile=process_time to any URL to profile the page load and download a calltree file. Open it with kcachegrind.

Add an around_filter :action_profiler to ApplicationController:

around_filter :action_profiler unless Rails.env.production?

Enable live profiling in production accessible to specific IP addresses:

ALLOWED_IPS = ['', '']
around_filter :action_profiler, :if =>
  lambda { |c| ALLOWED_IPS.include?(c.request.remote_ip) }

If you're using Ruby Enterprise Edition or a patched Ruby 1.8, you can profile memory and object allocation also: ?profile=memory or allocations.

This plugin uses an around_filter to profile the controller action only. Rack::Profiler, part of rack-contrib, can profile the entire Rails request.


Released under the MIT license, copyright © 2007-2009 37signals, LLC.