Monday, February 21, 2011

Outputting script execution time on Ruby on Rails?

Hi, is there a way to output the execution time on the screen? For example, in my Rails application if I call a controller from the index controller, I'd like to have the time it took to query the data displayed on the bottom of the page.

Thanks!

From stackoverflow
  • The Railscasts episode on Rack (ASCII version here) shows how to calculate the time elapsed, but it shows it as an HTML comment at the top of the response body.

    My approach would then be to put a certain token in my application layout (for example, <!-- REQUEST TIME -->) and then perform a gsub over the response body replacing that string with the request time, calculated as in the previous links.

    mr.flow3r : Looks like exactly what I was looking for. Thanks!

0 comments:

Post a Comment