Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatMap vs reduce with push vs filter x
(version: 1)
Comparing performance of:
flatMap vs reduce with push vs filter and map
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var arr = Array.from({length:10000}, (v, i) => ({name: i, assigned: Math.random() < 0.5}));
Tests:
flatMap
arr.flatMap((o) => (o.assigned ? [o.name] : []));
reduce with push
arr.reduce((a, o) => (o.assigned && a.push(o.name), a), [])
filter and map
arr.filter((v) => v.assigned).map((v) => v.name)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
flatMap
reduce with push
filter and map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
flatMap
5349.8 Ops/sec
reduce with push
16590.8 Ops/sec
filter and map
13399.7 Ops/sec
Related benchmarks:
flatMap vs reduce vs filter.map
flatMap() vs filter().map() vs array.reduce
flatMap vs reduce vs filter.map v2
flatMap vs reduce filtering performance
flatMap vs reduce vs loop filtering performance
flatMap vs reduce vs loop filtering performance vs filter
flatMap vs reduce vs loop filtering vs filter/map performance
Flat map + filter vs. Reduce
Reduce Push vs. flatMap vs 123
Comments
Confirm delete:
Do you really want to delete benchmark?