37signals / action_profiler

Profile Rails requests on a live app

This URL has Read+Write access

name age message
file MIT-LICENSE Thu Jan 29 13:55:31 -0800 2009 Rename license file [jeremy]
file README.rdoc Thu Jan 29 13:54:18 -0800 2009 Add license [jeremy]
file init.rb Sat Feb 07 12:57:24 -0800 2009 Install a dummy action_profiler class method if... [jeremy]
directory lib/ Thu Feb 19 15:21:57 -0800 2009 Clobber redirect responses so they're also prof... [jeremy]
README.rdoc

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 = ['127.0.0.1', '1.2.3.4']
  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.

License

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