Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatMap vs reduce-push vs flat
(version: 0)
Compare flatMap performance vs Array.reduce with Array.push
Comparing performance of:
reduce with push vs flatMap vs flat
Created:
2 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var data = []; for (let i = 0; i < 100000; i++) { data[i] = Array(10).fill(0); }
Tests:
reduce with push
data.reduce((acc, x) => { acc.push(...x); return acc; }, []);
flatMap
data.flatMap(x => x);
flat
data.flat(Infinity);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
reduce with push
flatMap
flat
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/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
reduce with push
33.5 Ops/sec
flatMap
23.2 Ops/sec
flat
19.3 Ops/sec
Related benchmarks:
flatMap vs reduce using push
Reduce Push vs. flatMap with subarrays
flatMap vs Reduce with push - test2
flatMap vs reduce (push)
Comments
Confirm delete:
Do you really want to delete benchmark?