3
0
Fork 0
websocketd/tests/performances/simple-stuff.cr

29 lines
447 B
Crystal
Raw Normal View History

2020-07-04 22:31:17 +02:00
require "benchmark"
hash_i = Hash(Int32, Int32).new
hash_str = Hash(String, String).new
full_hash = Hash(Int32, String).new
1000.times do |i|
full_hash[i] = "blah #{i}"
end
Benchmark.ips do |bm|
bm.report("hash[i32] = i32") do
hash_i[1] = 3
end
bm.report("hash[String] = String") do
hash_str["coucou"] = "truc"
end
bm.report("hash[500]") do
blah = full_hash[500]
end
bm.report("hash[800]") do
blah = full_hash[800]
end
end