Created
October 14, 2013 04:53
-
-
Save ntalbott/6970938 to your computer and use it in GitHub Desktop.
A little script to take memory profiling output from rdbtool and do some key prefix totalling
This file contains hidden or 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
#!/usr/bin/env ruby | |
hash = Hash.new{|h,k| h[k] = [0,0]} | |
aggregate_n = (ARGV[0] || 1).to_i | |
STDIN.each_line do |line| | |
parts = line.split(",") | |
key = parts[2][1..-2] | |
prefix = key.split(":")[0..(-1-aggregate_n)].join(":") | |
size = parts[3] | |
hash[prefix][0] += (size.to_i + key.size) | |
hash[prefix][1] += 1 | |
end | |
hash.entries.sort_by{|k,(size,count)| size}.reverse.each do |k,(size,count)| | |
puts "#{k}: #{size} (#{count})" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment