Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
FlatMap method vs for loop (small sample)
(version: 1)
Comparing performance of:
Flatmap vs Loop
Created:
5 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var arr = new Array(100).fill(1);
Tests:
Flatmap
arr.flatMap(() => [1, 2]);
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
Loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Flatmap
585091.6 Ops/sec
Loop
6483139.5 Ops/sec
Related benchmarks:
loop length recalculation
FlatMap method vs for loop
loop vs map 1994
for-push vs for-noop vs flatMap
flatmap vs for of vs custom flatMap (version 2)
JS Loop Tests
while, for, for-of, map
FlatMap method vs for loop 31-10-24
FlatMap method vs for loop big 31-10-24
Comments
Confirm delete:
Do you really want to delete benchmark?