@indutny/bencher
v2.0.0
Published
Simple benchmarking tool
Readme
@indutny/bencher
Simple JavaScript benchmarking tool inspired by my bad understanding of how Criterion.rs works.
Disclaimer
Let's be honest, I'm terrible at statistics. This approach that I took here is probably incorrect, but the results appear to be stable enough so I'm happy to use it for my personal projects.
Any ideas on improving the algorithm are very welcome!
Installation
npm install -g @indutny/bencherUsage
// Function to benchmark
export function benchmarkName() => {
let sum = 0;
for (let i = 0; i < 1e6; i++) {
sum += i;
}
// Make sure to return a side-effect value (possibly a result of the
// run) to ensure that the pure function calls are not optimized out by the
// JIT compiler.
return sum;
};$ bencher benchmark.js
benchmark.js/benchmarkName: 1’037.8 ops/sec (±18.8, p=0.001, n=98)LICENSE
This software is licensed under the MIT License.
