Skip to content

Instantly share code, notes, and snippets.

@starwels
Last active May 20, 2020 19:54
Show Gist options
  • Save starwels/81b2008711d4de527c4ea0de3d3023cc to your computer and use it in GitHub Desktop.
Save starwels/81b2008711d4de527c4ea0de3d3023cc to your computer and use it in GitHub Desktop.
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