Created
February 21, 2015 07:08
-
-
Save gauravs/61096caaff39b9a32daa 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' | |
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