[英]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.
例如,在我的Rails应用程序中,如果我从索引控制器调用一个控制器,我希望花时间来查询显示在页面底部的数据。
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. Rack上的Railscasts情节 ( 此处为 ASCII版本)展示了如何计算经过的时间,但在响应正文的顶部将其显示为HTML注释。
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. 然后,我的方法是在应用程序布局中放入一个特定的令牌(例如
<!-- REQUEST TIME -->
),然后在响应主体上执行gsub,以该字符串替换为请求时间,如前文所述链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.