Chaining

Benchmark created on


Setup

const empty = new Array(100).fill(undefined)

Test runner

Ready to run.

Testing in
TestOps/sec
multi-stage
const sumEvens = empty.map((_, i) => i).filter(i => i % 2 == 0).reduce((a, b) => a + b, 0)

console.log(sumEvens)
ready
single-reduce
const sumEvens = empty.reduce((a, _, i) => {
	if (i % 2 === 0) {
		return a + i
	}
	return a
}, 0)

console.log(sumEvens)
ready

Revisions

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