Skip to content

Instantly share code, notes, and snippets.

@futoase
Created April 5, 2016 15:23
Show Gist options
  • Save futoase/f38f73eecd94819f7251353883d58f4b to your computer and use it in GitHub Desktop.
Save futoase/f38f73eecd94819f7251353883d58f4b to your computer and use it in GitHub Desktop.
test.rb
require 'benchmark'
n = 10000000
Benchmark.bm do |x|
x.report ('to_sym') { n.times do ; 'test'.to_sym end }
x.report ('to_s') { n.times do ; :test.to_s end }
end
@futoase
Copy link
Author

futoase commented Apr 5, 2016

       user     system      total        real
to_sym  1.510000   0.010000   1.520000 (  1.529462)
to_s  1.270000   0.000000   1.270000 (  1.287681)

Ruby 2.3.0

@otiai10
Copy link

otiai10 commented Apr 5, 2016

πŸ™‡ 😍

to_sが

γ˜γ‚ƒγ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ£γ‹γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚γ‚“

早い

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment