Project

General

Profile

Bug #15018 ยป bench_node_argscat.rb

chopraanmol1 (Anmol Chopra), 08/22/2018 12:09 PM

 
require 'benchmark'
require 'memory_profiler'

Arr1 = [1,2,3,4]
def argscat
[*Arr1,5,6,7,8,9,10,11,12,13,14]
end

def argscat_multiple
[-3,-2,-1,0,*Arr1,5,6,7,8,9,10,11,12,13,14,*Arr1,5,6,7,8,9,10,11,12,13,*Arr1,5,6,7,8,9,10,11,12,13,14]
end

N = 1_000_000

Benchmark.bmbm do |b|
b.report('argscat') { N.times{ argscat } }
b.report('argscat_multiple') { N.times{ argscat_multiple } }
end

puts RubyVM::InstructionSequence.disasm(method(:argscat))
puts RubyVM::InstructionSequence.disasm(method(:argscat_multiple))


    (1-1/1)