Sha256: 250f29338f10af88cf4c1fcb6067071c31af4b0f15181e036fc4cac28fded6ba
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
# The call info visitor class does a depth-first traversal # across a thread's call stack. 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) # # 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 attr_reader :block, :thread def initialize(thread) @thread = thread end def visit(&block) @block = block self.thread.top_methods.each do |method_info| method_info.call_infos.each do |call_info| self.visit_call_info(call_info) end end end def visit_call_info(call_info) self.block.call(call_info, :enter) call_info.children.each do |child| visit_call_info(child) end self.block.call(call_info, :exit) end end end
Version data entries
5 entries across 5 versions & 1 rubygems