Last active
July 9, 2019 13:14
-
-
Save karloscodes/edb9292b6d3f9eaa46fa9d83c5ecc73a to your computer and use it in GitHub Desktop.
Ruby inmutable array concatenation. A prove benchmark.
This file contains hidden or 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
# ruby --version | |
# ruby 2.6.3p62 | |
require 'benchmark' | |
def without_splat(a, b, c); end | |
def with_splat(*a); end | |
Benchmark.bm do |x| | |
x.report do | |
(1..100_000).each do |_i| | |
without_splat(1, 2, 3) | |
end | |
end | |
end | |
# user system total real | |
# 0.006128 0.000000 0.006128 ( 0.006139) | |
Benchmark.bm do |x| | |
x.report do | |
(1..100_000).each do |_i| | |
with_splat(1, 2, 3) | |
end | |
end | |
end | |
# user system total real | |
# 0.015717 0.000000 0.015717 ( 0.015867) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment