未定义的方法“线程”;使用 ruby​​-prof

发布于 2024-11-09 03:57:32 字数 696 浏览 0 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

○闲身 2024-11-16 03:57:32

您确定它是 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 than printer.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. :(

深空失忆 2024-11-16 03:57:32

我遇到了这个错误。您是否有可能在代码中隐藏结果变量/将其分配给其他内容?确保您传入的“结果”确实是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文