Skip to content

Instantly share code, notes, and snippets.

@gauravs
Created February 21, 2015 07:08
Show Gist options
  • Save gauravs/61096caaff39b9a32daa to your computer and use it in GitHub Desktop.
Save gauravs/61096caaff39b9a32daa to your computer and use it in GitHub Desktop.
require 'benchmark'
n=100000
Benchmark.bm do |benchmark|
benchmark.report do
a=[]; n.times { a = a + [n] }
end
benchmark.report do
a=[]; n.times { a << n }
end
benchmark.report do
a=[1..n].map {|number| number}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment