ruby/benchmark/bm_hash_ident_sym.rb

5 строки
132 B
Ruby

h = {}.compare_by_identity
syms = ('a'..'z').to_a.map(&:to_sym)
syms.each { |s| h[s] = s }
200_000.times { syms.each { |s| h[s] } }