Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
filter-then-map vs reduce
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Native filter-map
48.6 Ops/sec
Reduce
97.0 Ops/sec
Script Preparation code:
var data = Array(1000000).fill({ filtering: true, mapping: 42 });
Tests:
Native filter-map
data.filter(({ filtering }) => filtering).map(({ mapping }) => mapping)
Reduce
data.reduce((acc, obj) => { if (obj.filtering) { acc.push(obj.mapping) } return acc }, [])