Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
FlatMap method vs for loop 31-10-24
(version: 0)
Compare the performance of for loop vs flatMap method
Comparing performance of:
flatMap vs for loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = Array(10_000).fill(0);
Tests:
flatMap
arr.flatMap(x => [x, x * 2]);
for loop
const n = arr.length; const acc = new Array(n * 2); for (let i = 0; i < n; i++){ const x = arr[i]; acc[i * 2] = x; acc[i * 2 + 1] = x * 2; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
flatMap
for loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/141.0.7390.96 Mobile/15E148 Safari/604.1
Browser/OS:
Chrome Mobile iOS 141 on iOS 18.6.2
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
flatMap
13301.6 Ops/sec
for loop
61604.1 Ops/sec
Related benchmarks:
flatMap() vs filter().map() vs for loop accumulator
FlatMap method vs for loop
for-noop vs flatMap
for-push vs for-noop vs flatMap
flatmap vs for of vs custom flatMap (version 2)
flatMap/reduce/loop
flatMap() vs filter().map() vs for loop accumulator vs forEach
flatMap vs reduce with spread vs reduce with push vs for of
FlatMap method vs for loop big 31-10-24
Comments
Confirm delete:
Do you really want to delete benchmark?