Created
November 20, 2013 20:13
-
-
Save codegoalie/7570180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 500_000 | |
Benchmark.bm(7) do |x| | |
x.report('append:') do | |
a = '' | |
n.times { a << 'a' } | |
end | |
x.report('+=:') do | |
a = '' | |
n.times { a += 'a' } | |
end | |
x.report('=+:') do | |
a = '' | |
n.times { a = a + 'a' } | |
end | |
end |
Author
codegoalie
commented
Nov 20, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment