Reduce vs for (v2)

Revision 2 of this benchmark created on


Setup

const sumReduce = (numbers) => numbers.reduce((a,b) => a + b, 0);

const sumFor = (numbers) => {
	let output = 0;
	for (const num of numbers) {
		output += num
	}
	return output
}

const count = 1_000_000
const inputNumbers = []

for (let i = 1; i <= count; ++i) {
    inputNumbers.push(i);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce
sumReduce(inputNumbers)
ready
For each
sumFor(inputNumbers)
ready

Revisions

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