Skip to content

Instantly share code, notes, and snippets.

@hughevans
Created March 16, 2012 05:31
Show Gist options
  • Save hughevans/2048678 to your computer and use it in GitHub Desktop.
Save hughevans/2048678 to your computer and use it in GitHub Desktop.
String concat speed.
user system total real
0.050000 0.000000 0.050000 ( 0.043481)
0.100000 0.010000 0.110000 ( 0.107440)
0.060000 0.000000 0.060000 ( 0.062976)
require 'benchmark'
first_name, last_name, x = 'Hugh', 'Evans', 100000
Benchmark.bm do |b|
b.report { x.times { "#{first_name} #{last_name}" }}
b.report { x.times { [first_name, last_name].join(' ') }}
b.report { x.times { first_name + ' ' + last_name }}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment