Lai Yu-Hsuan
Lai Yu-Hsuan

Reputation: 28081

How to profiling a slow action in Rails?

I have an action costs about 10s:

Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)

I tried to wrap the whole action with benchmark:

def action
  self.class.benchmark("Processing projects") do
    blahblahblah...
    ...
    ...
  end
end

But it's report looks strange:

how long does it take (692.2ms)
Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)

I guess that the hidden 8.8s is in certain before_filter or something. But how could I find it? Is it possible to profile an action call at once?

Upvotes: 3

Views: 623

Answers (1)

drhenner
drhenner

Reputation: 2230

I'm watching a great video on this stuff. at => windy city rails

Also check out http://guides.rubyonrails.org/performance_testing.html

rails profiler and ruby-prof might help. There are lots of good tools. good luck

Upvotes: 2

Related Questions