Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 是否有任何Rubygems或Rails方法可以显示生成网页所需的时间,以及控制器与视图中的时间?_Ruby On Rails_Rubygems - Fatal编程技术网

Ruby on rails 是否有任何Rubygems或Rails方法可以显示生成网页所需的时间,以及控制器与视图中的时间?

Ruby on rails 是否有任何Rubygems或Rails方法可以显示生成网页所需的时间,以及控制器与视图中的时间?,ruby-on-rails,rubygems,Ruby On Rails,Rubygems,或者,我可以编写大量的时间。现在并打印出减法,但是有没有一种标准的方法可以通过gems或Rails的标准和常规方法来完成呢?您可以在应用程序的顶部/末端添加一个statment.html.erb # application_controller.rb class ApplicationController < ActionController::Base before_filter :set_start_timer def set_start_timer @start_time

或者,我可以编写大量的
时间。现在
并打印出减法,但是有没有一种标准的方法可以通过gems或Rails的标准和常规方法来完成呢?

您可以在应用程序的顶部/末端添加一个statment.html.erb

# application_controller.rb
class ApplicationController < ActionController::Base
before_filter :set_start_timer

def set_start_timer
    @start_time = Time.now
end
end

# application.html.haml
=@start_time # this is the overall processing time
=Time.now # this is the start view render time
=yield
=Time.now # this is the view render time after processing content
#应用程序_controller.rb
类ApplicationController
您可能想看看Railscast和


我使用了托管计划,如果基本计划满足您的需求,或者您能负担得起付费计划,那么它肯定是一个很好的工具。我还并没有玩过,但它看起来很不错,尤其是免费的。看起来也不错,我可能只是想试一下。

这不是我在原始帖子中说的吗?如果你把它插入到application.html.erb中,你只需要写两条语句。然后修改
ApplicationController
,也做一个
@time\u start=time。现在
?+1。我也在使用NewRelic RPM来完成这样的任务,开发者模式很好。然而,免费版本并没有显示控制器和视图中的时间,只显示Ruby、数据库和外部服务中的时间。不过,在大多数情况下,找到性能瓶颈已经足够了。