如何在1.9.2中分析Ruby代码?

我可以用什么来分析1.9.2中的代码?所有版本的ruby-prof我都发现了针对1.9.2的段错误。 例如,当我添加
gem "ruby-prof"
到我的Rails项目的Gemfile并运行
bundle
bundle exec ruby-prof config/environment.rb
我得到了一个段错误。 镇上有新的剖析宝石吗?有没有办法让ruby-prof玩得好听?     
已邀请:
不确定它有什么帮助,但我偶然发现了这可能会增加更多的清晰度或引导你走另一条道路:http://www.devheads.net/development/ruby/core/segmentation-fault-when-using-ruby-教授-和红宝石192.htm。您可能想要根据该线程查看wycats的fork:https://github.com/wycats/ruby-prof 另外,我自己也没有试过,它可能不是你想要的,但是Github的Aman有一个用于Ruby的google-perftools端口: https://github.com/tmm1/perftools.rb     
正如@ chris.baglieri建议的那样,你可以使用
perftools.rb
gem来分析Ruby 1.9代码。
gem install perftools.rb
然后
require 'perftools'
PerfTools::CpuProfiler.start('profile_data') do
  # something cpu-intensive
end
`pprof.rb --text profile_data profile.txt`
`pprof.rb --pdf  profile_data profile.pdf`
    
您可以使用另一种流行的分析工具 - MethodProfiler 在目标类中找到慢速方法非常方便。     

要回复问题请先登录注册