▶ ruby hash_with_indifferent_access_benchmark.rb Calculating ------------------------------------- Common Hash#fetch access 47.253k i/100ms Common Hash#[] access 50.406k i/100ms HashWithIndifferentAccess#fetch Symbol 39.602k i/100ms HashWithIndifferentAccess#fetch String 41.055k i/100ms HashWithIndifferentAccess #[] Symbol 35.924k i/100ms HashWithIndifferentAccess #[] String 44.995k i/100ms Hash#with_indifferent_access #fetch Symbol 19.965k i/100ms Hash#with_indifferent_access #fetch String 19.782k i/100ms Hash#with_indifferent_access #[] Symbol 20.016k i/100ms Hash#with_indifferent_access #[] String 23.079k i/100ms ------------------------------------------------- Common Hash#fetch access 6.053M (±10.4%) i/s - 29.864M Common Hash#[] access 8.306M (±10.1%) i/s - 40.980M HashWithIndifferentAccess#fetch Symbol 1.932M (±12.8%) i/s - 9.465M HashWithIndifferentAccess#fetch String 1.994M (± 7.6%) i/s - 9.935M HashWithIndifferentAccess #[] Symbol 1.422M (± 5.6%) i/s - 7.113M HashWithIndifferentAccess #[] String 3.804M (± 9.7%) i/s - 18.808M Hash#with_indifferent_access #fetch Symbol 410.034k (± 5.4%) i/s - 2.056M Hash#with_indifferent_access #fetch String 414.702k (± 6.3%) i/s - 2.077M Hash#with_indifferent_access #[] Symbol 381.347k (± 5.6%) i/s - 1.902M Hash#with_indifferent_access #[] String 470.877k (± 6.0%) i/s - 2.354M Comparison: Common Hash#[] access: 8306261.5 i/s Common Hash#fetch access: 6053147.2 i/s - 1.37x slower HashWithIndifferentAccess #[] String: 3803546.0 i/s - 2.18x slower HashWithIndifferentAccess#fetch String: 1993671.6 i/s - 4.17x slower HashWithIndifferentAccess#fetch Symbol: 1932004.0 i/s - 4.30x slower HashWithIndifferentAccess #[] Symbol: 1422367.3 i/s - 5.84x slower Hash#with_indifferent_access #[] String: 470876.8 i/s - 17.64x slower Hash#with_indifferent_access #fetch String: 414701.6 i/s - 20.03x slower Hash#with_indifferent_access #fetch Symbol: 410033.7 i/s - 20.26x slower Hash#with_indifferent_access #[] Symbol: 381347.2 i/s - 21.78x slower