Skip to content

Instantly share code, notes, and snippets.

@seanders
Created December 1, 2015 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanders/015c417e8d38053be00e to your computer and use it in GitHub Desktop.
Save seanders/015c417e8d38053be00e to your computer and use it in GitHub Desktop.
require 'benchmark'
n = 10 ** 5
first_array = (1..300).to_a
second_array = (301..600).to_a
Benchmark.bmbm do |x|
x.report('(+) Concat:') { n.times do; first_array + second_array; end; }
x.report('(flatten) Flatten:') { n.times do; [ first_array, second_array].flatten; end; }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment