Created
January 11, 2017 18:44
-
-
Save askldjd/4d105ddd341ee33e9a74a8111d175bf1 to your computer and use it in GitHub Desktop.
Look for a single generation of ruby heap and print out the allocation source.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
class Analyzer | |
def initialize(filename) | |
@filename = filename | |
end | |
def analyze | |
data = [] | |
File.open(@filename) do |f| | |
f.each_line do |line| | |
parsed=JSON.parse(line) | |
data << parsed if parsed["generation"] == ARGV[1].to_i | |
end | |
end | |
data.group_by{|row| "#{row["file"]}:#{row["line"]}"} | |
.sort{|a,b| b[1].count <=> a[1].count} | |
.each do |k,v| | |
puts "#{k} * #{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