Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatmap vs reduce t2
(version: 1)
Comparing performance of:
flatmap vs reduce
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ let a = Array.from({ length: 10000 }, (v, i) => ({ name: i, station: Array.from({ length: 20 }, (v2, i2) => i2) }) )
Tests:
flatmap
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ a.flatMap((l) => l.station.map(s=>({line:l.name,station:s})))
reduce
a.reduce((acc, curr) => { for (const s of curr.station) { acc.push({ line: curr.name, staion: s }) } return acc; }, [])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
flatmap
reduce
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
flatmap
196.4 Ops/sec
reduce
211.3 Ops/sec
Related benchmarks:
for / reduce
reduce()+push() vs map()
flatmap
flatMap vs reduce 1111
flatMap vs reduce 1111111
flatMap vs reduce 999
flatMap vs reduce 999912345
flatMap vs reduce 99991234
flatmap vs reduce t
Comments
Confirm delete:
Do you really want to delete benchmark?