This project is archived and is in readonly mode.

#3891 ✓invalid
Lourens Naudé

Hash#symbolize_keys! performance

Reported by Lourens Naudé | February 7th, 2010 @ 11:27 PM

Hi,

Attached is a patch to Hash#symbolize_keys! that yields a 5 to 9x faster runtime for my test cases ( http://gist.github.com/297755 ) :

methodmissing:~ lourens$ ruby hash_bench.rb
Rehearsal -----------------------------------------------------------------------
Hash#orig_symbolize_keys! , nil key 3.510000 0.170000 3.680000 ( 3.720439)
Hash#symbolize_keys! , nil key 0.360000 0.000000 0.360000 ( 0.392987)
Hash#orig_symbolize_keys! 2.020000 0.080000 2.100000 ( 2.168747)
Hash#symbolize_keys! 0.360000 0.010000 0.370000 ( 0.371135)
-------------------------------------------------------------- total: 6.510000sec

                                      user     system      total        real

Hash#orig_symbolize_keys! , nil key 3.390000 0.160000 3.550000 ( 3.551547)
Hash#symbolize_keys! , nil key 0.350000 0.000000 0.350000 ( 0.361843)
Hash#orig_symbolize_keys! 3.400000 0.160000 3.560000 ( 3.571425)
Hash#symbolize_keys! 0.360000 0.000000 0.360000 ( 0.362906)

  • Lourens

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages