lib/stackprof/report.rb in stackprof-0.2.0 vs lib/stackprof/report.rb in stackprof-0.2.1
- old
+ new
@@ -3,14 +3,10 @@
module StackProf
class Report
def initialize(data)
@data = data
-
- frames = {}
- @data[:frames].each{ |k,v| frames[k.to_s] = v }
- @data[:frames] = frames
end
attr_reader :data
def frames(sort_by_total=false)
Hash[ *@data[:frames].sort_by{ |iseq, stats| -stats[sort_by_total ? :total_samples : :samples] }.flatten(1) ]
@@ -163,20 +159,20 @@
lines = info[:lines]
maxline = lines ? lines.keys.max : line + 5
f.printf "%s (%s:%d)\n", info[:name], file, line
f.printf " samples: % 5d self (%2.1f%%) / % 5d total (%2.1f%%)\n", info[:samples], 100.0*info[:samples]/overall_samples, info[:total_samples], 100.0*info[:total_samples]/overall_samples
- if (callers = data[:frames].map{ |id, other| [other[:name], other[:edges][frame.to_i]] if other[:edges] && other[:edges].include?(frame.to_i) }.compact).any?
+ if (callers = data[:frames].map{ |id, other| [other[:name], other[:edges][frame]] if other[:edges] && other[:edges].include?(frame) }.compact).any?
f.puts " callers:"
callers = callers.sort_by(&:last).reverse
callers.each do |name, weight|
f.printf " % 5d (% 8s) %s\n", weight, "%3.1f%%" % (100.0*weight/info[:total_samples]), name
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.to_s][:name], weight] }
+ callees = callees.map{ |k, weight| [data[:frames][k][:name], weight] }
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