未定义的方法“线程”;使用 ruby-prof
我正在尝试使用 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>'
有什么建议吗?
I'm trying to use ruby-prof to profile some code. It seems to work up until the line indicated below:
require 'rubygems'
require 'ruby-prof'
result = RubyProf.start do
puts "do stuff..."
end
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, {}) #fails here
Error:
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>'
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定它是
printer.print(STDOUT, {})
而不是printer.print(STDOUT, 0)
吗?看看关闭垃圾收集是否有帮助。请参阅以下错误报告: https://github.com/rdp/ruby-prof/issues /80
另外,看看在 Ruby 1.8 (MRI) 下运行它是否有帮助。
如果您可以生成更具体的错误报告,那也会很有用。 :(
Are you sure it's meant to be
printer.print(STDOUT, {})
rather thanprinter.print(STDOUT, 0)
?See if turning off garbage collection helps. See the following bug report: https://github.com/rdp/ruby-prof/issues/80
Also, see if running it under Ruby 1.8 (MRI) helps.
If you can produce a more specific bug report, that'd be also useful. :(
我遇到了这个错误。您是否有可能在代码中隐藏结果变量/将其分配给其他内容?确保您传入的“结果”确实是 RubyProf 结果对象。
I got this bug. Is it possible that you are shadowing the result variable / assigning it to something else later on in your code? Make sure the "result" that you're passing in is really the RubyProf result object.