Last active
December 24, 2015 22:39
-
-
Save fidelisrafael/6874640 to your computer and use it in GitHub Desktop.
Simple benchmark (simple test from Rodrigo Alves : https://gist.github.com/rodrigoalvesvieira/6255267)
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' | |
Benchmark.bm(10) do |x| | |
x.report("Array#join") { | |
10000.times do | |
["'", ("a".."z").to_a.join("' , '"), "'"].join | |
end | |
} | |
x.report("String#<<") { | |
10000.times do | |
res = "" | |
("a".."z").to_a.each do |l| | |
res << "'#{l}'" << ", " | |
end | |
end | |
} | |
end |
Author
fidelisrafael
commented
Oct 7, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment