DEV: Apply syntax_tree formatting to script/*

This commit is contained in:
David Taylor
2023-01-07 11:53:14 +00:00
parent ff508d1ae5
commit 436b3b392b
143 changed files with 8905 additions and 7353 deletions

View File

@ -6,8 +6,8 @@
# rbtrace -p 15193 -e 'Thread.new{require "objspace"; ObjectSpace.trace_object_allocations_start; GC.start(full_mark: true); ObjectSpace.dump_all(output: File.open("heap.json","w"))}.join'
#
#
require 'set'
require 'json'
require "set"
require "json"
if ARGV.length != 2
puts "Usage: diff_heaps [ORIG.json] [AFTER.json]"
@ -16,26 +16,26 @@ end
origs = Set.new
File.open(ARGV[0], "r").each_line do |line|
parsed = JSON.parse(line)
origs << parsed["address"] if parsed && parsed["address"]
end
File
.open(ARGV[0], "r")
.each_line do |line|
parsed = JSON.parse(line)
origs << parsed["address"] if parsed && parsed["address"]
end
diff = []
File.open(ARGV[1], "r").each_line do |line|
parsed = JSON.parse(line)
if parsed && parsed["address"]
diff << parsed unless origs.include? parsed["address"]
File
.open(ARGV[1], "r")
.each_line do |line|
parsed = JSON.parse(line)
if parsed && parsed["address"]
diff << parsed unless origs.include? parsed["address"]
end
end
end
diff.group_by do |x|
[x["type"], x["file"], x["line"]]
end.map { |x, y|
[x, y.count]
}.sort { |a, b|
b[1] <=> a[1]
}.each { |x, y|
puts "Leaked #{y} #{x[0]} objects at: #{x[1]}:#{x[2]}"
}
diff
.group_by { |x| [x["type"], x["file"], x["line"]] }
.map { |x, y| [x, y.count] }
.sort { |a, b| b[1] <=> a[1] }
.each { |x, y| puts "Leaked #{y} #{x[0]} objects at: #{x[1]}:#{x[2]}" }