Created
September 17, 2013 21:31
-
-
Save misfo/6600943 to your computer and use it in GitHub Desktop.
Testing IceNine.deep_freeze performanc
This file contains 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
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