Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
FlatMap vs For-Loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser:
Firefox 145
Operating system:
Windows
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
flatMap
56460.2 Ops/sec
for loop
58772.7 Ops/sec
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:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
flatMap
const input = Array.from({ length: 1000 }, (_, i) => [i, i + 1]); const result = input.flatMap(pair => pair);
for loop
const input = Array.from({ length: 1000 }, (_, i) => [i, i + 1]); const result = []; for (let i = 0; i < input.length; i++) { result.push(input[i][0], input[i][1]); }