Object
This method detect recursive calls in the call graph.
# File lib/ruby-prof/profile.rb, line 15 def detect_recursion(thread) visited_methods = Hash.new do |hash, key| hash[key] = 0 end visitor = CallInfoVisitor.new(thread) visitor.visit do |call_info, event| case event when :enter visited_methods[call_info.target] += 1 call_info.recursive = (visited_methods[call_info.target] > 1) when :exit visited_methods[call_info.target] -= 1 if visited_methods[call_info.target] == 0 visited_methods.delete(call_info.target) end end end end
eliminate some calls from the graph by merging the information into callers. matchers can be a list of strings or regular expressions or the name of a file containing regexps.
# File lib/ruby-prof/profile.rb, line 37 def eliminate_methods!(matchers) matchers = read_regexps_from_file(matchers) if matchers.is_a?(String) eliminated = [] threads.each do |thread| matchers.each{ |matcher| eliminated.concat(eliminate_methods(thread.methods, matcher)) } end eliminated end
This method gets called once profiling has been completed but before results are returned to the user. Thus it provides a hook to do any necessary post-processing on the call graph.
# File lib/ruby-prof/profile.rb, line 8 def post_process self.threads.each do |thread| detect_recursion(thread) end end
Generated with the Darkfish Rdoc Generator 2.