↩ī¸Ž

bench-press

Benchmark operations

Use

import benchpress from 'bench-press';

console.log(
    benchpress(() => myFunction())
);

// Running 1000 times took 54ms

Options

Message

console.log(
    benchpress(
        () => myFunction(),
        {
            message: 'myFunction ✖ ${iterations} = ${duration}',
        }
    )
);

// myFunction ✖ 1000 = 54

Iterations

console.log(
    benchpress(
        () => myFunction(),
        {
            iterations: 1e5,
        }
    )
);

// Running 100000 times took 54ms