Profiling controllers


I’ve built some fairly complex controllers and I’d like to profile them. What’s the best way to go about this? I suspect the profiling script shipped with Rails doesn’t work well with controllers. I looked at railsbench, but it doesn’t work well because the controllers use acts_as_authenticated.

What does everyone use?



Jake Cutter wrote:

I've built some fairly complex controllers and I'd like to profile them.
What's the best way to go about this?

This probably isn't the *best* way to go about it, but for a quick hack
to get some results you could try this:

1. Add

require 'profiler'

at the top of your 'whatever_controller.rb'.

2. After the 'def my_action' line of the action you want to profile,


3. At the end of the action, add


Then when you run that action in your browser, it'll write a file into
log/profiler.log that contains a profile for the controller part of
that action.

Quick and dirty, but maybe it'll do the job (or inspire you to write
something nicer!).