Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling view in Rails

I have a big view, which takes very long to finish to render the content. How is the best method to profile, which part of the view is taking the most time ? I have read about ruby-prof, but I'm not sure, where to put in it, to profile the view rendering. If other options exists, I want to know them too.

like image 725
astropanic Avatar asked Feb 14 '11 07:02

astropanic


1 Answers

The easiest way to quickly get to bottleneck is using NewRelics Developer mode which works locally.

  1. Make sure you have ruby-prof and newrelic_rpm in your Gemfile.
  2. Navigate to localhost:3000/newrelic and start profiling (in the right bar)
  3. Make an actual request to page of your app you want to profile, possibly multiple times to make sure you don't measure some caching & stuff.
  4. Navigate back to newrelic developer mode, pick request trace.
  5. Sort the table by "self" column. This is crucial since the default sorting by total time is misleading.
  6. Look on top-10 calls, how are they called and you probably find the bottleneck.

Disclaimer: I've pushed this sorting feature to newrelic's developer mode, so I am biased. However try if for yourself.

like image 64
johno Avatar answered Oct 13 '22 01:10

johno