Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2009 14:57
Show Gist options
  • Save anonymous/111067 to your computer and use it in GitHub Desktop.
Save anonymous/111067 to your computer and use it in GitHub Desktop.
require 'benchmark'
include Benchmark
n = 1000000
Benchmark.bm do |test|
test.report("Double quotes:") do
n.times do |x|
str = "A string with a \newline"
str = "Interpolates #{12345}"
end
end
test.report("Single quotes:") do
n.times do |x|
str = 'A string with a \newline'
str = 'Interpolates #{12345}'
end
end
end
# user system total real
# Double quotes: 5.490000 2.120000 7.610000 ( 7.652372)
# Single quotes: 4.220000 2.100000 6.320000 ( 6.345824)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment