Skip to content

Commit fd2cffa

Browse files
committed
Use data[:frames]
frames is sorted and we can avoid calculating it for a few formats
1 parent a493d06 commit fd2cffa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/stackprof/report.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def overall_samples
4040
end
4141

4242
def max_samples
43-
@data[:max_samples] ||= frames.max_by{ |addr, frame| frame[:samples] }.last[:samples]
43+
@data[:max_samples] ||= @data[:frames].values.max_by{ |frame| frame[:samples] }[:samples]
4444
end
4545

4646
def files
@@ -192,7 +192,7 @@ def print_flamegraph(f, skip_common, alphabetical=false)
192192
end
193193

194194
def flamegraph_row(f, x, y, weight, addr)
195-
frame = frames[addr]
195+
frame = @data[:frames][addr]
196196
f.print ',' if @rows_started
197197
@rows_started = true
198198
f.puts %{{"x":#{x},"y":#{y},"width":#{weight},"frame_id":#{addr},"frame":#{frame[:name].dump},"file":#{frame[:file].dump}}}
@@ -213,7 +213,7 @@ def convert_to_d3_flame_graph_format(name, stacks, depth)
213213
weight += stack.last
214214
end
215215
else
216-
frame = frames[val]
216+
frame = @data[:frames][addr]
217217
child_name = "#{ frame[:name] } : #{ frame[:file] }"
218218
child_data = convert_to_d3_flame_graph_format(child_name, child_stacks, depth + 1)
219219
weight += child_data["value"]

0 commit comments

Comments
 (0)