1

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?

recursive_acronym
  • 2,981
  • 6
  • 40
  • 59

2 Answers2

0

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.

Eli Albért
  • 686
  • 1
  • 6
  • 16
0

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. :(

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338