Skip to content

Instantly share code, notes, and snippets.

@gpherguson
Created February 14, 2013 23:49
Show Gist options
  • Save gpherguson/4957463 to your computer and use it in GitHub Desktop.
Save gpherguson/4957463 to your computer and use it in GitHub Desktop.
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