Rails ruby-prof 和基准测试
我正在运行 Rails 2.2.2。 我读过一些关于 ruby-prof 和分析 Rails 应用程序的文章。 我对事情到底是如何运作的感到困惑。
我最初使用的是这个教程 http: //snippets.aktagon.com/snippets/255-How-to-profile-your-Rails-and-Ruby-applications-with-ruby-prof 来分析我的应用程序,它可以工作。 这涉及编写您自己的配置文件环境并运行 > RAILS_ENV=profiling ./script/performance/request -n 100 profiling/homepage.rb
所以这是我的困惑。 不知何故,这运行了 ruby-prof 并打开了所有统计数据等,但我看不到 ruby-prof 实际被调用的任何地方。
然后我进一步阅读,似乎 2.2.2 内置了基准测试/分析。所以我在性能部分编写了一个测试文件,如下所示
require 'test_helper'
require 'performance_test_help'
# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionController::PerformanceTest
def test_worksheet
get '/reduction/worksheet'
end
end
并运行
耙子测试:简介
这是否等同于我上面所做的,只是现在它集成到了整个rails框架中?
我的下一个问题是这样的。 原始脚本输出一个平面文件和 html 文件,但我不知道如何自动获取树文件以使用 KCacheGrind 打开,或者在我的情况下使用 MacCallGrind 打开。 我可以在脚本调用中添加格式吗?
编辑:通过 rake 测试运行脚本似乎实际上生成了一个树文件,太棒了。 然而,Mac CallGrind 在尝试解析它时似乎挂起。 有人知道查看这些树文件的其他工具吗?
I'm running Rails 2.2.2. I've read a few articles about ruby-prof and profiling a rails app. And I'm confused as to how things are really working.
I was originally using this tutorial
http://snippets.aktagon.com/snippets/255-How-to-profile-your-Rails-and-Ruby-applications-with-ruby-prof
to profile my app, and it works. This involves writing your own profile environment and running > RAILS_ENV=profiling ./script/performance/request -n 100 profiling/homepage.rb
So here's my confusion. Somehow, this runs ruby-prof and opens up all the stats etc, but I can't see anywhere where ruby-prof is ever actually called.
So then I read further, and it seems 2.2.2 has benchmarking/profiling built in. So I write a test file in the performance section like so
require 'test_helper'
require 'performance_test_help'
# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionController::PerformanceTest
def test_worksheet
get '/reduction/worksheet'
end
end
and run
rake test:profile
Is this equivalent to what I was doing above, but just now it's integrated into the whole rails framework?
My next question is this. The original script ouput a flat file and html file, but I couldn't figure out how to also get a tree file automatically to open up with KCacheGrind, or in my case MacCallGrind. Can I add formats into my script call?
Edit: running the scripts through rake test seem to actually produce a tree file, great. Mac CallGrind however seems to hang when trying to parse it. Anyone know other tools for viewing these tree files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,完全一样,我一定是在读旧教程。 所有基准测试和分析现在都在 Rails 中,这非常棒。 它输出 txt、html 和树文件,也很棒。 现在,如果 Only MacCallGrind 可以工作,我就无法安装查看树文件所需的 4gb KDE 软件包。
Turns out, it's exactly the same, I must have been reading an old tutorial. All the benchmarking and profiling is now in Rails which is awesome. And it outputs txt,html and tree files, also awesome. Now if Only MacCallGrind would work, there's no way I'm installing the 4gb of KDE packages needed just to view a tree file.
Brad,您应该联系 MacCallGrind 的作者,看看是否有更新,或者他/她是否对您的文件有修复。
哦,没错,就是我。 请通过符号 aggmedia.net 向 richard 发送电子邮件,因为即将发布更新,并且我希望获得 Ruby/Rails 支持。
Brad, you should contact the author of MacCallGrind and see if there's an update, or whether he/she has a fix for your files.
Oh that's right, that's me. Please email at richard at symbol aggmedia.net, as there is an update about to come out, and I'd love to have Ruby/Rails support available.