Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created October 12, 2012 12:09
Show Gist options
  • Select an option

  • Save jonleighton/3878907 to your computer and use it in GitHub Desktop.

Select an option

Save jonleighton/3878907 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
bar = 'bar'
Benchmark.ips do |r|
r.report('concatenation') { 'foo' << bar }
r.report('interpolation') { "foo#{bar}" }
end
Calculating -------------------------------------
concatenation 45410 i/100ms
interpolation 46498 i/100ms
-------------------------------------------------
concatenation 1822091.6 (±9.9%) i/s - 9036590 in 5.011248s
interpolation 1830436.5 (±10.4%) i/s - 9067110 in 5.010211s
@ender672
Copy link

Similar benchmark I made a few months ago. JRuby & Rubinius results are quite interesting.

https://gist.github.com/1707529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment