filter&amp vs reduce

Benchmark created on


Setup

const a100 = Array.from({length: 100}, (el, i) => i)

const a1000 = Array.from({length: 1000}, (el, i) => i)

const a10000 = Array.from({length: 10000}, (el, i) => i)

Test runner

Ready to run.

Testing in
TestOps/sec
100tc1
const result = a100.filter(i => i % 2 !== 0)
ready
100tc2
const result = a100.reduce((acc, el) => {
	el % 2 !== 0 && acc.push(el)
	return acc
}, [])
ready

Revisions

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