HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Tests:
  • transform1

    x
     
    const transform1 = (rowTemplate) => {
        if (!rowTemplate?.length) {
            return [];
        }
        const rows = rowTemplate.length;
        const cols = rowTemplate[0].length;
        const result = [];
        for (let col = 0; col < cols; col++) {
            for (let row = 0; row < rows; row++) {
                result.push(rowTemplate[row][col]);
            }
        }
        return result;
    };
    var t1 = [
        ["1", "1", "2", "3", "4", "4"],
        ["1", "1", "5", "6", "4", "4"]
    ];
    for (var i=0; i < 10000; i++) {
        transform1(t1);
    }
  • transform2

     
    const transform2 = (rowTemplate) => {
        if (!rowTemplate?.length) {
            return [];
        }
        const rows = rowTemplate.length;
        const cols = rowTemplate[0].length;
        const result = new Array(rows * cols);
        for (let col = 0; col < cols; col++) {
            for (let row = 0; row < rows; row++) {
                result.push(rowTemplate[row][col]);
            }
        }
        return result;
    };
    var t1 = [
        ["1", "1", "2", "3", "4", "4"],
        ["1", "1", "5", "6", "4", "4"]
    ];
    for (var i=0; i < 10000; i++) {
        transform2(t1);
    }
  • transform3

     
    const transform3 = (rowTemplate) => {
        if (!rowTemplate?.length) {
            return [];
        }
        const rows = rowTemplate.length;
        const cols = rowTemplate[0].length;
        const result = new Array(rows * cols);
        for (let col = 0; col < cols; col++) {
            for (let row = 0; row < rows; row++) {
                result[col * cols + row] = rowTemplate[row][col];
            }
        }
        return result;
    };
    var t1 = [
        ["1", "1", "2", "3", "4", "4"],
        ["1", "1", "5", "6", "4", "4"]
    ];
    for (var i=0; i < 10000; i++) {
        transform3(t1);
    }
  • transform4

     
    const transform4 = (rowTemplate) => {
        if (!rowTemplate?.length) {
            return [];
        }
        const rows = rowTemplate.length;
        const cols = rowTemplate[0].length;
        const result = [];
        for (let col = 0; col < cols; col++) {
            for (let row = 0; row < rows; row++) {
                result[col * cols + row] = rowTemplate[row][col];
            }
        }
        return result;
    };
    var t1 = [
        ["1", "1", "2", "3", "4", "4"],
        ["1", "1", "5", "6", "4", "4"]
    ];
    for (var i=0; i < 10000; i++) {
        transform4(t1);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    transform1
    transform2
    transform3
    transform4

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 27 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Windows
View result in a separate tab
Test name Executions per second
transform1 3802.0 Ops/sec
transform2 2807.2 Ops/sec
transform3 2677.6 Ops/sec
transform4 2403.2 Ops/sec