如何在 View 中显示页面加载时间,类似于日志文件显示“19ms内完成200 OK( View :16.8ms |模型:0.497ms)”
最佳答案
您可能想更好地使用Seconds:
class ApplicationController < ActionController::Base
before_filter :set_start_time
def set_start_time
@start_time = Time.now.to_f
end
end
查看代码:
Page Rendered in <%= sprintf('%.3f', (Time.now.to_f - @start_time) ) %> seconds
关于ruby-on-rails - 在Rails中显示页面加载时间3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4187985/