How can I profile a controller action?
如何配置控制器操作?
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.
我的一个观点是花了相当长的时间来渲染,我想把它分解。我看到了script / performance / profiler,但似乎只能访问全局范围。
3 个解决方案
#1
8
ruby-prof is the way to go. Here's a howto, How to profile your Rails and Ruby applications with ruby-prof.
ruby-prof是要走的路。这是一个howto,如何使用ruby-prof配置您的Rails和Ruby应用程序。
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.
如果将它与可视化工具(如kcachegrind)结合使用,则可以轻松地将作为应用程序代码的代码与框架代码分开。
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用户小组讨论过这些工具:使用ruby-prof和kcachegrind让你的rails应用程序发挥作用。
#2
2
The Ruby on Rails console should show you which partials are taking a while to render. If that's not enough, you could install the new relic gem (https://github.com/newrelic/rpm) and use that in developer mode which will give you an overview of what's going on.
Ruby on Rails控制台应该向您显示哪些部分需要花费一段时间才能呈现。如果这还不够,你可以安装新的遗物宝石(https://github.com/newrelic/rpm)并在开发者模式下使用它,它将为你提供正在发生的事情的概述。
If you're deploying on Heroku you can add the free version of rpm which will give you the same statistics on your running application.
如果您在Heroku上部署,可以添加免费版本的rpm,它将为您提供与正在运行的应用程序相同的统计信息。
Ruby has a profiler (http://ruby-prof.rubyforge.org/) which will show you memory usage, call times, etc., but it might be hard to disseminate your code from the framework code.
Ruby有一个分析器(http://ruby-prof.rubyforge.org/),它将向您显示内存使用情况,调用时间等,但可能很难从框架代码中传播您的代码。
#3
0
I've had some success with https://github.com/bhb/rack-perftools_profiler
我在https://github.com/bhb/rack-perftools_profiler上取得了一些成功
It'll let you profile a single or multiple requests for any of cputime, methods, object allocations or walltime, and integrate nicely via Rack middleware.
它可以让您分析任何cputime,方法,对象分配或walltime的单个或多个请求,并通过Rack中间件很好地集成。
#1
8
ruby-prof is the way to go. Here's a howto, How to profile your Rails and Ruby applications with ruby-prof.
ruby-prof是要走的路。这是一个howto,如何使用ruby-prof配置您的Rails和Ruby应用程序。
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.
如果将它与可视化工具(如kcachegrind)结合使用,则可以轻松地将作为应用程序代码的代码与框架代码分开。
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用户小组讨论过这些工具:使用ruby-prof和kcachegrind让你的rails应用程序发挥作用。
#2
2
The Ruby on Rails console should show you which partials are taking a while to render. If that's not enough, you could install the new relic gem (https://github.com/newrelic/rpm) and use that in developer mode which will give you an overview of what's going on.
Ruby on Rails控制台应该向您显示哪些部分需要花费一段时间才能呈现。如果这还不够,你可以安装新的遗物宝石(https://github.com/newrelic/rpm)并在开发者模式下使用它,它将为你提供正在发生的事情的概述。
If you're deploying on Heroku you can add the free version of rpm which will give you the same statistics on your running application.
如果您在Heroku上部署,可以添加免费版本的rpm,它将为您提供与正在运行的应用程序相同的统计信息。
Ruby has a profiler (http://ruby-prof.rubyforge.org/) which will show you memory usage, call times, etc., but it might be hard to disseminate your code from the framework code.
Ruby有一个分析器(http://ruby-prof.rubyforge.org/),它将向您显示内存使用情况,调用时间等,但可能很难从框架代码中传播您的代码。
#3
0
I've had some success with https://github.com/bhb/rack-perftools_profiler
我在https://github.com/bhb/rack-perftools_profiler上取得了一些成功
It'll let you profile a single or multiple requests for any of cputime, methods, object allocations or walltime, and integrate nicely via Rack middleware.
它可以让您分析任何cputime,方法,对象分配或walltime的单个或多个请求,并通过Rack中间件很好地集成。