Created
August 14, 2015 02:56
-
-
Save marocchino/f8e157eee14967a1b36e to your computer and use it in GitHub Desktop.
Array#* vs Array.new
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 = 500_000_000_000_000 | |
Benchmark.bm do |x| | |
x.report { ["a"] * 10 } | |
x.report { Array.new(10, "a") } | |
end | |
# user system total real | |
# 0.000000 0.000000 0.000000 ( 0.000012) | |
# 0.000000 0.000000 0.000000 ( 0.000007) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment