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-profThen 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
require 'ruby_profiler'class ApplicationController < ActionController::Base
include RubyProfiler
end
Then in the controller I just need to
def some_action result = RubyProf.profile { ... } write_profile(result, 5, RubyProfiler::GRAPH_HTML) end
source: ruby_profiler.rb
Comments
Add a comment