Skip to content

Instantly share code, notes, and snippets.

@alno
Created January 30, 2012 13:39
Show Gist options
  • Save alno/1704455 to your computer and use it in GitHub Desktop.
Save alno/1704455 to your computer and use it in GitHub Desktop.
Benchmark: interpolation vs concatenation in Ruby
require 'benchmark'
count = 1000000
Benchmark.benchmark do |bm|
bm.report("concat") { count.times { 11.to_s + '/' + 12.to_s } }
bm.report("interp") { count.times { "#{11}/#{12}" } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment