Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flatMap() vs filter().map() vs reduce() v8
flatMap vs filter map vs reduce()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 14; Mobile; rv:141.0) Gecko/141.0 Firefox/141.0
Browser:
Firefox Mobile 141
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
reduce()
9K/s
filter().map()
6K/s
flatMap()
4K/s
View exact numbers
Test name
Executions per second
✓
reduce()
8,874 Ops/sec
filter().map()
5,708 Ops/sec
flatMap()
4,180 Ops/sec
Script Preparation code:
var arr = []; var i = 0; while (i <= 10000) arr[i] = i++;
Tests:
filter().map()
arr.filter(x => x % 2).map(x => x/100)
flatMap()
arr.flatMap(x => x % 2 ? x/100 : [])
reduce()
arr.reduce((newArray, x) => { if (x % 2) { newArray.push(x / 100) } return newArray }, [])