Skip to content

Instantly share code, notes, and snippets.

@komagata
Created October 30, 2015 09:41
Show Gist options
  • Save komagata/a2ceb5af4152cc3227fb to your computer and use it in GitHub Desktop.
Save komagata/a2ceb5af4152cc3227fb to your computer and use it in GitHub Desktop.
require 'benchmark'
num = 10000
Benchmark.bm 2 do |r|
r.report '+' do
str = ''
num.times do
str += 'a'
end
end
r.report '<<' do
str = ''
num.times do
str << 'a'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment