如何分析 Rails 中的缓慢动作?
我有一个动作花费大约 10 秒:
Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)
我尝试用 benchmark
包装整个动作:
def action
self.class.benchmark("Processing projects") do
blahblahblah...
...
...
end
end
但它的报告看起来很奇怪:
how long does it take (692.2ms)
Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)
我猜隐藏的 8.8s 是在某些 before_filter
或某物。但我怎样才能找到它呢?是否可以立即分析行动调用?
I have an action costs about 10s:
Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)
I tried to wrap the whole action with benchmark
:
def action
self.class.benchmark("Processing projects") do
blahblahblah...
...
...
end
end
But it's report looks strange:
how long does it take (692.2ms)
Completed 200 OK in 9489ms (Views: 1.3ms | ActiveRecord: 71.6ms)
I guess that the hidden 8.8s is in certain before_filter
or something. But how could I find it? Is it possible to profile an action call at once?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在观看有关此内容的精彩视频。在 => 风城市轨道
另请查看http://guides.rubyonrails.org/performance_testing.html
Rails Profiler 和 ruby-prof 可能会有所帮助。有很多好的工具。祝你好运
I'm watching a great video on this stuff. at => windy city rails
Also check out http://guides.rubyonrails.org/performance_testing.html
rails profiler and ruby-prof might help. There are lots of good tools. good luck