Profiling Rails end-to-end

I wanted to do some profiling of a Rails app, so I did a little digging and found ruby-prof with new and improved call graphs. Plus it’s very fast. The install couldn’t be easier

sudo gem install ruby-prof```
Then I wanted to see if I could get this to run in before and after filters, I haven't had any luck, though I haven't tried all that hard. Since I wanted to be able to do this relatively easily I threw together a mini module to handle the report generation piece for me. So now I can profile a controller action by adding this to my application controller
```ruby

require 'ruby_profiler'

class ApplicationController < ActionController::Base
  include RubyProfiler
end
</code>
</pre>

Then in the controller I just need to
```ruby

def some_action
  result = RubyProf.profile {
    ...
  }
  write_profile(result, 5, RubyProfiler::GRAPH_HTML)
end
</code>
</pre>

source: <a href="/dropbox/ruby_profiler.rb">ruby_profiler.rb</a>