Skip to content

@rosenfeld /report.txt
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Performance comparison: strings vs symbols in Ruby
ruby symbols-performance.rb
Rehearsal ------------------------------------
0.540000 0.010000 0.550000 ( 0.543421)
0.680000 0.020000 0.700000 ( 0.705931)
--------------------------- total: 1.250000sec
user system total real
0.240000 0.000000 0.240000 ( 0.244554)
0.380000 0.000000 0.380000 ( 0.391517)
require 'benchmark'
hashes = []
1_000_000.times { hashes << { some_key_name: 1, 'some_key_name' => 2 }}
Benchmark.bmbm do |x|
x.report { hashes.map{|h| h[:some_key_name]} }
x.report { hashes.map{|h| h['some_key_name']} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.