Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
flatMap vs reduce vs filter.map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
filter().map()
16.2M/s
reduce()
4.3M/s
flatMap()
4.0M/s
View exact numbers
Test name
Executions per second
✓
filter().map()
16,231,886 Ops/sec
reduce()
4,347,334 Ops/sec
flatMap()
3,985,652 Ops/sec
Script Preparation code:
var arr = Array.from({length: 20}, () => Math.floor(Math.random() * 100));;
Tests:
flatMap()
arr.flatMap((e) => e > 50 ? e / 2 : []);
reduce()
arr.reduce((acc, curr) => curr > 50 ? [...acc, curr / 2] : acc, []);
filter().map()
arr.filter((e) => e > 50).map((e) => e / 2);