Skip to content

Instantly share code, notes, and snippets.

@judofyr
Created February 18, 2011 20:02
Show Gist options
  • Save judofyr/834302 to your computer and use it in GitHub Desktop.
Save judofyr/834302 to your computer and use it in GitHub Desktop.
gems = Hash.new(0)
gems_size = Hash.new(0)
total = 0
`du -ks ~/.rvm/gems/*/gems/*`.each_line do |line|
size = line[/\d+/].to_i
name = line[/\/([^\/\n]+)$/, 1]
gems[name] += 1
gems_size[name] = size
total += size
end
bloats = 0
length = gems.keys.map { |a| a.length }.sort.last
gems.each do |name, num|
size = gems_size[name]
bloat = (num - 1) * size
bloats += bloat
puts "#{num} of #{name}".ljust(length + 5) + "Size: #{size}kB"
end
puts
puts " Total gems: #{total / 1024}MB"
puts " Total bloat: #{bloats / 1024}MB"
puts " #{100*bloats/total}% of your gems are duplicates."
@judofyr
Copy link
Author

judofyr commented Feb 25, 2011

Well, it only checks if you have duplicate gems in your RVM installation, so if you don't use RVM it won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment