Local lambda vs Inline vs IIFE

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Lambda
const func = () => {
    const lambda = (count) => {
        let sum = 0;
        for (let i = 0; i < count; i++) {
            sum += Math.sqrt(i);
        }
        return sum;
    };

    const result = lambda(10000);
    return result;
};
ready
inline
const func = () => {
    let sum = 0;
    for (let i = 0; i < 10000; i++) {
        sum += Math.sqrt(i);
    }

    return sum;
};
ready
IIFE
const func = () => {
    const result = (() => {
        let sum = 0;
        for (let i = 0; i < 10000; i++) {
            sum += Math.sqrt(i);
        }
        return sum;
    })();

    return result;
};
ready

Revisions

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