我正在尝试使用ruby-prof来分析一些代码。它似乎一直在运行,直到下面指示的行:
require 'rubygems'
require 'ruby-prof'
result = RubyProf.start do
puts "do stuff..."
end
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, {}) #fails here错误:
hulkster@ubuntu:~/code/clancms$ ruby ./memtest.rb
/home/hulkster/.rvm/gems/ruby-1.9.2-p180/gems/ruby-prof-0.10.7/lib/ruby-prof/flat_printer.rb:31:in `print_threads': undefined method `threads' for RubyProf:Module (NoMethodError)
from /home/hulkster/.rvm/gems/ruby-1.9.2-p180/gems/ruby-prof-0.10.7/lib/ruby-prof/flat_printer.rb:25:in `print'
from ./memtest.rb:8:in `<main>'有什么建议吗?
发布于 2011-05-20 07:23:08
您确定应该是printer.print(STDOUT, {})而不是printer.print(STDOUT, 0)吗
看看关闭垃圾收集是否有帮助。请参阅以下错误报告:https://github.com/rdp/ruby-prof/issues/80
另外,看看在Ruby1.8 (MRI)下运行它是否有帮助。
如果你能生成一个更具体的bug报告,那也是很有用的。:(
发布于 2015-12-30 04:18:03
我得了个虫子。是否有可能在代码中隐藏result变量/将其赋值给后面的其他变量?确保您传入的“结果”是真正的RubyProf结果对象。
https://stackoverflow.com/questions/6060868
复制相似问题