for(i), for(of), foreach

Compact view

Benchmark publishedon

Setup

const testcase = Array.from({ length: 2**18 }, () => Math.random() * 1000);

Test Runner

Initializing...

Testing in
Test CaseOps/sec
for(i)

    let sum = 0;
    for (let i = 0; i < testcase.length; i++) {
        sum += Math.sqrt(testcase[i] * testcase[i] + 123.456);
    }
    return sum;
ready
for(of)

    let sum = 0;
    for (const value of testcase) {
        sum += Math.sqrt(value * value + 123.456);
    }
    return sum;
ready
foreach

    let sum = 0;
    testcase.forEach(value => {
        sum += Math.sqrt(value * value + 123.456);
    });
    return sum;
ready

Revisions

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

Revision 1
publishedon