Adam Lee
Adam Lee

Reputation: 3003

Outputting script execution time on Ruby on Rails?

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!

Upvotes: 1

Views: 1574

Answers (1)

pantulis
pantulis

Reputation: 1705

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.

Upvotes: 3

Related Questions