public
Created

Test of double vs single quotes with escaped tabs vs embedded tabs

  • Download Gist
quotes_test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
require 'benchmark'
 
n = 10_000_000
 
Benchmark.bm(24) do |b|
5.times do
b.report('double-quotes with \t') { n.times { "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" } }
b.report('double-quotes with <tab>') { n.times { " " } }
b.report('single-quotes with <tab>') { n.times { ' ' } }
end
end
 
5.times do
Benchmark.bm(24) do |b|
b.report('double-quotes with \t') { n.times { "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" } }
b.report('double-quotes with <tab>') { n.times { " " } }
b.report('single-quotes with <tab>') { n.times { ' ' } }
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.