Array destructuring parameter vs Array access

Benchmark created on


Setup

a = [1,2,3,4,5,6,7,8,9,10];
b = a.slice().reverse();

function A(
[a0, a1, a2, a3, a4, a5, a6, a7, a8, a9],
[b0, b1, b2, b3, b4, b5, b6, b7, b8, b9]
) {
	return [a0 + b0,  a1 + b1,  a2 + b2,  a3 + b3,  a4 + b4,  a5 + b5,  a6 + b6,  a7 + b7,  a8 + b8, a9 + b9];
}
function B(
a0,
b0
) {
	return [a0[0] + b0[0],  a0[1] + b0[1],  a0[2] + b0[2],  a0[3] + b0[3],  a0[4] + b0[4],  a0[5] + b0[5],  a0[6] + b0[6],  a0[7] + b0[7],  a0[8] + b0[8], a0[9] + b0[9]];
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array destructuring parameter
A(a, b);
ready
Array access
B(a, b);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.