Skip to content

Instantly share code, notes, and snippets.

@misfo
Created September 17, 2013 21:31
Show Gist options
  • Save misfo/6600943 to your computer and use it in GitHub Desktop.
Save misfo/6600943 to your computer and use it in GitHub Desktop.
Testing IceNine.deep_freeze performanc
require 'benchmark'
require 'ice_nine'
def self.nested(depth, width, array_length)
hash = {}
1.upto(width) do |n|
hash[n.to_s] = n.to_s
end
unless depth == 1
hash[(width - 1).to_s] = array_length.times.map {|n| nested(depth - 1, width, array_length) }
hash[width.to_s] = nested(depth - 1, width, array_length)
end
hash
end
hash = nested(3, 5, 100)
results = Benchmark.measure do
IceNine.deep_freeze hash
end
puts results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment