Skip to content

Instantly share code, notes, and snippets.

@toothrot
Created March 21, 2013 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toothrot/5214870 to your computer and use it in GitHub Desktop.
Save toothrot/5214870 to your computer and use it in GitHub Desktop.
require 'benchmark'
Benchmark.bmbm do |x|
x.report "double quotes" do
10_000_000.times do
"foo"
end
end
x.report "single quotes" do
10_000_000.times do
'foo'
end
end
end
$ ruby strings_bench.rb
Rehearsal -------------------------------------------------
double quotes 2.810000 0.010000 2.820000 ( 2.809821)
single quotes 2.810000 0.000000 2.810000 ( 2.815568)
---------------------------------------- total: 5.630000sec
user system total real
double quotes 2.810000 0.000000 2.810000 ( 2.808336)
single quotes 2.810000 0.000000 2.810000 ( 2.812794)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment