简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM