Skip to content

Instantly share code, notes, and snippets.

@askldjd
Created January 11, 2017 18:45
Show Gist options
  • Save askldjd/3ab1854230e9d45b85e51477eb69bce1 to your computer and use it in GitHub Desktop.
Save askldjd/3ab1854230e9d45b85e51477eb69bce1 to your computer and use it in GitHub Desktop.
Perform a top level analysis on the ruby heap dump.
require 'json'
class Analyzer
def initialize(filename)
@filename = filename
end
def analyze
data = []
File.open(@filename) do |f|
f.each_line do |line|
data << (parsed=JSON.parse(line))
end
end
data.group_by{|row| row["generation"]}
.sort{|a,b| a[0].to_i <=> b[0].to_i}
.each do |k,v|
puts "generation #{k} objects #{v.count}"
end
end
end
Analyzer.new(ARGV[0]).analyze
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment