lib/stackprof/report.rb in stackprof-0.2.1 vs lib/stackprof/report.rb in stackprof-0.2.2

- old
+ new

@@ -90,15 +90,15 @@ sample << "#{call} (%2.1f%%)\\rof " % (call*100.0/overall_samples) if call < total sample << "#{total} (%2.1f%%)\\r" % (total*100.0/overall_samples) fontsize = (1.0 * call / max_samples) * 28 + 10 size = (1.0 * total / overall_samples) * 2.0 + 0.5 - f.puts " #{frame} [size=#{size}] [fontsize=#{fontsize}] [penwidth=\"#{size}\"] [shape=box] [label=\"#{info[:name]}\\n#{sample}\"];" + f.puts " \"#{frame}\" [size=#{size}] [fontsize=#{fontsize}] [penwidth=\"#{size}\"] [shape=box] [label=\"#{info[:name]}\\n#{sample}\"];" if edges = info[:edges] edges.each do |edge, weight| size = (1.0 * weight / overall_samples) * 2.0 + 0.5 - f.puts " #{frame} -> #{edge} [label=\"#{weight}\"] [weight=\"#{weight}\"] [penwidth=\"#{size}\"];" + f.puts " \"#{frame}\" -> \"#{edge}\" [label=\"#{weight}\"] [weight=\"#{weight}\"] [penwidth=\"#{size}\"];" end end end f.puts "}" end @@ -169,11 +169,11 @@ end end if callees = info[:edges] f.printf " callees (%d total):\n", info[:total_samples]-info[:samples] - callees = callees.map{ |k, weight| [data[:frames][k][:name], weight] } + callees = callees.map{ |k, weight| [data[:frames][k][:name], weight] }.sort_by{ |k,v| -v } callees.each do |name, weight| f.printf " % 5d (% 8s) %s\n", weight, "%3.1f%%" % (100.0*weight/(info[:total_samples]-info[:samples])), name end end @@ -186,10 +186,10 @@ list = files.map{ |file, vals| [file, vals.values.inject([0,0]){ |sum, n| add_lines(sum, n) }] } list = list.sort_by{ |file, samples| -samples[1] } list = list.first(limit) if limit list.each do |file, vals| total_samples, samples = *vals - f.printf "% 5d (%2.1f%%) / % 5d (%2.1f%%) %s\n", total_samples, (100.0*total_samples/overall_samples), samples, (100.0*samples/overall_samples), file + f.printf "% 5d (%5.1f%%) / % 5d (%5.1f%%) %s\n", total_samples, (100.0*total_samples/overall_samples), samples, (100.0*samples/overall_samples), file end end def print_file(filter, f = STDOUT) filter = /#{Regexp.escape filter}/ unless Regexp === filter