views:

32

answers:

2

Alternatively, I can write a bunch of Time.now and print out the subtractions but is there a standard way it can be done by gems or by Rails' standard and conventional method?

A: 

You could add a statment on the top/end of your application.html.erb?

# application_controller.rb
class ApplicationController < ActionController::Base
before_filter :set_start_timer

def set_start_timer
    @start_time = Time.now
end
end

# application.html.haml
=@start_time # this is the overall processing time
=Time.now # this is the start view render time
=yield
=Time.now # this is the view render time after processing content
Lichtamberg
isn't that what i said in the original post?
動靜能量
If you insert it into your application.html.erb you only have to write 2 single statements at all.
Lichtamberg
and then modify `ApplicationController` to also do a `@time_start = Time.now`?
動靜能量
Updated my post...
Lichtamberg
+2  A: 

You might want to take a look at Railscast 98 and 161.

I've used NewRelic's hosted plan and it's definitely a great tool if the basic plan meets your needs or you can afford a paid plan. I haven't played around with the developer mode yet but it looks pretty good, especially for being free. Rack::Bug look nice too I might just have to take it for a spin.

aNoble
+1. I'm also using NewRelic RPM for such tasks, developer mode works just fine. However, free version doesn't show you the time in controller vs the view, only the time in Ruby vs Database vs External services. Still, it's enough to find performance bottlenecks in most cases.
buru