From 098b0ba572d624acdc2af1925db7feda4b72881e Mon Sep 17 00:00:00 2001 From: normal Date: Thu, 9 Oct 2014 03:44:12 +0000 Subject: benchmark/bm_hash_aref_sym*.rb: force static symbols Dynamic symbols hash more slowly because they need extra method dispatch in rb_any_hash. I am not sure if dynamic symbols are a realistic use case as hash keys, so this commit only restores performance when comparing against versions of Ruby which lack dsyms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/bm_hash_aref_sym.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'benchmark/bm_hash_aref_sym.rb') diff --git a/benchmark/bm_hash_aref_sym.rb b/benchmark/bm_hash_aref_sym.rb index 54298ffc9e..f75d163fe6 100644 --- a/benchmark/bm_hash_aref_sym.rb +++ b/benchmark/bm_hash_aref_sym.rb @@ -1,4 +1,9 @@ h = {} -syms = ('a'..'z').to_a.map(&:to_sym) +syms = ('a'..'z').to_a +begin + syms = eval("%i[#{syms.join(' ')}]") +rescue SyntaxError # <= 1.9.3 + syms.map!(&:to_sym) +end syms.each { |s| h[s] = s } 200_000.times { syms.each { |s| h[s] } } -- cgit v1.2.3