class RubyProf::CallTreeVisitor
puts method_names
end
method_names << call_tree.target.full_name if event == :enter
visitor.visit do |call_tree, event|
method_names = Array.new
visitor = RubyProf::CallTreeVisitor.new(result.threads.first.call_tree)
either :enter or :exit.
parameters, the event and the call_tree instance. Event will be
the block provided in the #visit method. The block is passed two
list of call infos. At each call_tree node, the visitor executes
The call info visitor class does a depth-first traversal across a
def initialize(call_tree, max_depth: nil)
def initialize(call_tree, max_depth: nil) @call_tree = call_tree @max_depth = max_depth end
def visit(&block)
def visit(&block) visit_call_tree(@call_tree, 0, &block) end
def visit_call_tree(call_tree, depth, &block)
def visit_call_tree(call_tree, depth, &block) yield call_tree, :enter if @max_depth.nil? || depth < @max_depth call_tree.children.each do |child| visit_call_tree(child, depth + 1, &block) end end yield call_tree, :exit end