Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
FlatMap method vs for loop asdas
(version: 1)
Compare the performance of for loop vs flatMap method
Comparing performance of:
flatMap vs for loop
Created:
4 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = Array(50).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:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
flatMap
831973.2 Ops/sec
for loop
8110313.5 Ops/sec
Related benchmarks:
flatMap() vs filter().map() vs for loop accumulator
FlatMap method vs for loop
flatMap vs for in vs forEach
for-noop vs flatMap
flatmap vs for of vs custom flatMap (version 2)
FlatMap method vs for loop 31-10-24
FlatMap method vs for loop big 31-10-24
flatMap() vs filter().map() vs for loop accumulator vs forEach vs for of loop
FlatMap method vs for loop (small sample)
Comments
Confirm delete:
Do you really want to delete benchmark?