Sha256: 55676df66b9fcc39cd065d072a29f6281717881317f24722ac3160927682f1e5
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# 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.top_call_infos) # # method_names = Array.new # # visitor.visit do |call_info, event| # method_names << call_info.target.full_name if event == :enter # end # # puts method_names module RubyProf class CallInfoVisitor def initialize(call_infos) @call_infos = CallInfo.roots_of(call_infos) end def visit(&block) @call_infos.each do |call_info| visit_call_info(call_info, &block) end end private def visit_call_info(call_info, &block) yield call_info, :enter call_info.children.each do |child| visit_call_info(child, &block) end yield call_info, :exit end end end
Version data entries
3 entries across 3 versions & 2 rubygems