Skip to content

Instantly share code, notes, and snippets.

View woahdae's full-sized avatar

Woody Peterson woahdae

  • Seattle, WA, United States
View GitHub Profile
def profile(unit = :M)
# trying to see where our memory is going
population = Hash.new{|h,k| h[k] = [0,0]}
array_sizes = Hash.new{|h,k| h[k] = 0}
ObjectSpace.each_object do |object|
# rough estimates, see http://eigenclass.org/hiki.rb?ruby+space+overhead
size = case object
when Array
array_sizes[object.size / 10] += 1
case object.size