Skip to content

@gpherguson /quotes_test.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Test of double vs single quotes with escaped tabs vs embedded tabs
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
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.