Skip to content

Instantly share code, notes, and snippets.

@levinalex
Created January 22, 2009 16:53
Show Gist options
  • Save levinalex/50607 to your computer and use it in GitHub Desktop.
Save levinalex/50607 to your computer and use it in GitHub Desktop.
# print a sorted list of all classes in the ruby vm sorted by count
#
def object_statistics(minimum = 2)
counts = {}
ObjectSpace.each_object do |o|
counts[o.class] = (counts[o.class] || 0) + 1
end
counts.to_a.reject {|k,v| v < minimum}.sort_by { |k,v| -v }.each { |k,v| puts "%6d " % v + k.to_s }
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment