Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
flatMap() vs filter().map() vs reduce() vs forOf loop v8
flatMap vs filter map vs reduce() vs forOf loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 16; Mobile; rv:147.0) Gecko/147.0 Firefox/147.0
Browser:
Firefox Mobile 147
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 months ago
Test name
Executions per second
filter().map()
8027.5 Ops/sec
flatMap()
5151.3 Ops/sec
reduce()
11904.7 Ops/sec
forof loop
3306.3 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 }, [])
forof loop
newArray = []; for (x of arr){ if (x % 2) { newArray.push(x / 100) } }