Skip to content

Commit

Permalink
Reduce more array allocations by nesting blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmaroli committed Apr 24, 2019
1 parent 94ff680 commit 37bfc5f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/memory_profiler/results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ def pretty_print(io = $stdout, **options)

if options[:detailed_report] != false
io.puts
["allocated", "retained"]
.product(["memory", "objects"])
.product(["gem", "file", "location", "class"])
.each do |(type, metric), name|
["allocated", "retained"].each do |type|
["memory", "objects"].each do |metric|
["gem", "file", "location", "class"].each do |name|
scale_data = metric == "memory" && options[:scale_bytes]
dump "#{type} #{metric} by #{name}", self.send("#{type}_#{metric}_by_#{name}"), io, scale_data
end
end
end
end

io.puts
Expand Down

0 comments on commit 37bfc5f

Please sign in to comment.