Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatMap() vs filter().map() vs reduce() v4
(version: 0)
flatMap vs filter map vs reduce()
Comparing performance of:
filter().map() vs flatMap() vs reduce()
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; var i = 0; while (i <= 1E5) arr[i] = i++;
Tests:
filter().map()
arr.filter(x => x % 12).filter(x => x % 5).filter(x => x % 3).map(x => x/100)
flatMap()
arr.flatMap(x => x % 12 && x % 5 && x % 3 ? x/100 : [])
reduce()
arr.reduce((newArray, x) => { if (x % 12 && x % 5 && x % 3) { newArray.push(x / 100) } return newArray }, [])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
filter().map()
flatMap()
reduce()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Browser/OS:
Chrome 140 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
filter().map()
316.9 Ops/sec
flatMap()
655.6 Ops/sec
reduce()
748.7 Ops/sec
Related benchmarks:
flatMap vs reduce vs filter.map
flatMap vs reduce vs filter.map v2
flatMap vs reduce filtering performance
flatMap vs reduce vs loop filtering vs filter/map performance
Reduce Push vs. flatMap vs 123
Comments
Confirm delete:
Do you really want to delete benchmark?