Array Destructuring Overhead

Benchmark created on


Setup

points = [];

for (let i = 0; i < 500; ++i) {
	points.push([Math.random(), Math.random()]);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Explicit
let sum = 0;

for (let i = 0; i < points.length; ++i) {
	const point = points[i];
	sum += point[0] + point[1];
}
ready
Destructuring
let sum = 0;

for (let i = 0; i < points.length; ++i) {
	const [x, y] = points[i];
	sum += x + y;
}
ready

Revisions

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