class RubyProf::CallInfoVisitor

The call info visitor class does a depth-first traversal across a list of method infos. At each call_info node, the visitor executes the block provided in the visit method. The block is passed two parameters, the event and the call_info instance. Event will be either :enter or :exit.

visitor = RubyProf::CallInfoVisitor.new(result.threads.first.root_methods)

method_names = Array.new

visitor.visit do |call_info, event|
  method_names << call_info.target.full_name if event == :enter
end

puts method_names

Public Class Methods

new(root_methods) click to toggle source
   # File lib/ruby-prof/call_info_visitor.rb
18 def initialize(root_methods)
19   @call_infos = root_methods.map(&:callers).flatten
20 end

Public Instance Methods

visit(&block) click to toggle source
   # File lib/ruby-prof/call_info_visitor.rb
22 def visit(&block)
23   @call_infos.each do |call_info|
24     visit_call_info(call_info, &block)
25   end
26 end