lib/ruby-prof/printers/dot_printer.rb in ruby-prof-0.18.0 vs lib/ruby-prof/printers/dot_printer.rb in ruby-prof-1.0.0
- old
+ new
@@ -2,10 +2,11 @@
require 'set'
module RubyProf
# Generates a graphviz graph in dot format.
+ #
# To use the dot printer:
#
# result = RubyProf.profile do
# [code to profile]
# end
@@ -82,11 +83,11 @@
total_time = thread.total_time
thread.methods.sort_by(&sort_method).reverse_each do |method|
total_percentage = (method.total_time/total_time) * 100
next if total_percentage < min_percent
- name = method_name(method).split("#").last
+ name = method.full_name.split("#").last
puts "#{dot_id(method)} [label=\"#{name}\\n(#{total_percentage.round}%)\"];"
@seen_methods << method
print_edges(total_time, method)
end
end
@@ -111,16 +112,15 @@
end
end
end
def print_edges(total_time, method)
- method.aggregate_children.sort_by(&:total_time).reverse.each do |child|
-
- target_percentage = (child.target.total_time / total_time) * 100.0
+ method.callers.sort_by(&:total_time).reverse.each do |call_info|
+ target_percentage = (call_info.target.total_time / total_time) * 100.0
next if target_percentage < min_percent
# Get children method
- puts "#{dot_id(method)} -> #{dot_id(child.target)} [label=\"#{child.called}/#{child.target.called}\" fontsize=10 fontcolor=#{EDGE_COLOR}];"
+ puts "#{dot_id(method)} -> #{dot_id(call_info.target)} [label=\"#{call_info.called}/#{call_info.target.called}\" fontsize=10 fontcolor=#{EDGE_COLOR}];"
end
end
# Silly little helper for printing to the @output
def puts(str)