views:

2868

answers:

6

I've been looking for profiling tools for Rails for a while. I'm currently playing and testing ruby-prof and railsbench, but I kinda frustrated with the amount of tweaking and mangling required to make then work.

Althought I don't mind (much) the tweaking, I'd like to know if is there any other, more straight-forward and easy to use, tools to profile a Rails app? Which tools you recommend?

+3  A: 

http://rails-analyzer.rubyforge.org/ might be what you're looking for.

I highly recommend the Production log Analyzer for a clear list of most time consuming actions and also the action profiler.

added: For the production log analyzer you don't need any configuration, it just parses the production log and gives you a list of most time consuming actions, including min/max/median time. Very good to see where you should profile/optimize more.

deathy
+8  A: 

New Relic offers Rails profiling including a free 'Lite' version.

Corbin March
Also, it's worth to mention that you can use "developer" mode, which allows you to use it locally without a NewRelic account.
Ivan
+3  A: 

You should also take a look at FiveRuns' TuneUp. It is completely free, installs as a plugin into your Rails application. Keep in mind that it does send data back to their server (mostly very harmless information), but that might bother some people (namely government agencies would be very unhappy about that). I think you'll be surprised how great the tool is considering it is free.

Another nice feature of it is that you can post your run data for others to comment and help you diagnose your long queries, or bad code.

Kevin Elliott
Tune up link seems to be invalid today, 9 Aug 2010 :(
Chris Kimpton
+2  A: 

If you are under OSX Leopard, you can give DTrace a try.

Adrian
+11  A: 

You can use the built in profiler as well:

$ ruby script/performance/profiler 'User.new' 5
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
189.25     1.76      1.76        1  1760.00  1760.00  Profiler__.start_profile
 43.01     2.16      0.40      115     3.48     3.91  ActiveRecord::ConnectionAdapters::Column#simplified_type
  8.60     2.24      0.08       15     5.33     8.67  Array#each
  7.53     2.31      0.07      115     0.61     5.39  ActiveRecord::ConnectionAdapters::Column#initialize
  6.45     2.37      0.06      115     0.52     0.52  ActiveRecord::ConnectionAdapters::Column#type_cast
  5.38     2.42      0.05      690     0.07     0.07  Regexp#===
  0.00     2.69      0.00       10     0.00     0.00  Process.times
  0.00     2.69      0.00       10     0.00     0.00  Benchmark.times
mwilliams
+2  A: 

rack bug is pretty cool http://github.com/brynary/rack-bug

Sam Saffron