如何在 Ruby on Rails 中分析请求? [英] How can I profile a request in Ruby on Rails?

查看:60
本文介绍了如何在 Ruby on Rails 中分析请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分析控制器操作?

我的一个观点需要相当长的时间来呈现,我想将其分解.我看到 script/performance/profiler,但这似乎只能访问全局范围.

One of my views is taking quite some time to render, and I'd like to break it down. I see script/performance/profiler, but that seems to only have access to the global scope.

推荐答案

ruby-prof 是要走的路.这是一个操作方法,如何使用 ruby​​-prof 分析您的 Rails 和 Ruby 应用程序.

ruby-prof is the way to go. Here's a howto, How to profile your Rails and Ruby applications with ruby-prof.

如果您将它与诸如 kcachegrind 之类的可视化工具结合使用,您可以轻松地将作为您的应用程序代码的代码与框架代码分开.

If you use it in combination with a visualisation tool such as kcachegrind, you can easily separate the code that is your application code from the framework code.

不久前,我在当地的 Ruby 用户组中就这些工具进行了演讲:使用 ruby​​-prof 和 kcachegrind 使您的 rails 应用程序变得更好.

I gave a talk on these tools at my local Ruby-users group a while back: Making your rails app kick ass with ruby-prof and kcachegrind.

这篇关于如何在 Ruby on Rails 中分析请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆