map filter

Benchmark created on


Description

check map+filter vs reduce

Setup

const arr = Array({length: 1000}).map((_, i) => Math.floor(Math.random() * i))

Test runner

Ready to run.

Testing in
TestOps/sec
map+filter
arr.map(item => item % 2).filter(Boolean)
ready
reduce
arr.reduce((prev, item) => {
	if (item % 2) {
		prev.push(item)
	}
	return prev
}, [])
ready

Revisions

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