Skip to content

Instantly share code, notes, and snippets.

@tamouse
Created August 10, 2014 06:50
Show Gist options
  • Save tamouse/6dc4e1d1158f3ac92d93 to your computer and use it in GitHub Desktop.
Save tamouse/6dc4e1d1158f3ac92d93 to your computer and use it in GitHub Desktop.
SIngle quote vs. Double quote with no interpolation
[1] pry(main)> Benchmark.ips do |x|
[1] pry(main)* x.config(:time => 5, :warmup => 2)
[1] pry(main)* x.report('single quote') { 'hi there' }
[1] pry(main)* x.report('doulbe quote') { "hi there" }
[1] pry(main)* x.compare!
[1] pry(main)* end
Calculating -------------------------------------
single quote 72754 i/100ms
doulbe quote 75296 i/100ms
-------------------------------------------------
single quote 5228109.3 (±31.8%) i/s - 21680692 in 4.996617s
doulbe quote 5223542.7 (±31.4%) i/s - 21835840 in 4.996256s
Comparison:
single quote: 5228109.3 i/s
doulbe quote: 5223542.7 i/s - 1.00x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment