TEST

Benchmark created on


Setup

// Function to generate a random date string
function randomDate() {
    const year = Math.floor(Math.random() * (2023 - 1970 + 1)) + 1970;
    const month = String(Math.floor(Math.random() * 12) + 1).padStart(2, "0");
    const day = String(Math.floor(Math.random() * 31) + 1).padStart(2, "0");
    return `${year}-${month}-${day}`;
}

// Function to generate a random floating-point number as a string
function randomFloatAsString() {
    const randomFloat = (Math.random() * (1000 - 0) + 0).toFixed(2);
    return randomFloat;
}

// Generate 4100 random values
const randomValues = Array.from({ length: 4100 }, () => ({
    date: randomDate(),
    value: randomFloatAsString(),
}));

const  L1 = L2 = L3 = U1 = U2 = U3 = randomValues;

function testpower(a, b) {
    const outputPower = [];
    if (a.length === b.length) {
        for (let x = 0; x < a.length; x++) {
            outputPower.push({
                x: new Date(a[x].date).getTime(),
                y: parseFloat(a[x].value) * parseFloat(b[x].value),
            });
        }
    }
    return outputPower;
}

Test runner

Ready to run.

Testing in
TestOps/sec
test 1
const P1 = testpower(U1, L1);
const P2 = testpower(U2, L2);
const P3 = testpower(U3, L3);

console.log(P1,P2,P3)
ready
test 2
const P1 = testpower(U1, L1);
const P2 = testpower(U2, L2);
const P3 = testpower(U3, L3);

console.log(P1,P2,P3)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.