HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
 
 var arr = [];
 var size = 1000;
 var size_n = 100;
 for (let i = 0; i < size; i++) {
     const innerData = [];
     for (let j = 0; j < 2; j++) { // Still 2 sub-arrays per data
         const subArray = [];
         for (let k = 0; k < size_n; k++) {
             subArray.push(i * size_n + j * size_n + k); // Unique values
         }
         innerData.push(subArray);
     }
     arr.push({
         data: innerData
     });
 }
Tests:
  • for

     
    var result = [];
        for (let i = 0; i < arr.length; i++) {
            const data = arr[i].data;
            for (let j = 0; j < data.length; j++) {
                const subArray = data[j];
                for (let k = 0; k < subArray.length; k++) {
                    result.push(subArray[k]);
                }
            }
        }
  • for of

     
    var result = [];
        for (let item of arr) {
            for (let subArray of item.data) {
                for (let element of subArray) {
                    result.push(element);
                }
            }
        }
  • flatMap

     
    arr.flatMap(x => x.data).flat()
  • flatMap(n)

     
    arr.map(x => x.data).flat(2);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    for of
    flatMap
    flatMap(n)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 28 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
for 955.3 Ops/sec
for of 811.4 Ops/sec
flatMap 369.5 Ops/sec
flatMap(n) 365.1 Ops/sec