Last active
May 20, 2020 19:54
-
-
Save starwels/81b2008711d4de527c4ea0de3d3023cc 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' | |
array = [] | |
array2 = [] | |
CONST = 100_000 | |
TEMPLATE = [[1,2],[1,2]] | |
time2 = Benchmark.measure do | |
CONST.times do | |
array2 += TEMPLATE | |
end | |
end | |
time = Benchmark.measure do | |
CONST.times do | |
array << TEMPLATE | |
end | |
array.flatten(1) | |
end | |
puts time | |
puts time2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment