@feltmaps/benchmarking
v1.1.0
Published
A benchmarking tool for JS code
Downloads
1
Readme
Felt benchmarking
This package allows to benchmark javascript code on the browser.
How it works
Runs Benchmark
implementations and measures the time it takes to execute a single run. If that run takes less than 5ms (which is the minimum resolution of performance.now()
, see Performance.now() on MDN), we keep incrementing the number of iterations iterationsPerSample per run until it takes more than 5ms. Once that happens, we capture 210 samples via running iterationsPerSample iterations per sample
Create a benchmark
export default class FilterCreate extends Benchmark {
bench() {
findPrimes(1000);
}
}
Create a benchmark suite
const suite = new BenchmarkingSuite();
Add benchmarks to the suite
suite.register("Filter", "version 1", new FilterCreate());
Adding multiple benchmarks with the same name but different version will compare them in the results website
suite.register("Filter", "version 1", new FilterCreate());
suite.register("Filter", "version 2", new FilterCreate2());
Run the suite
suite.run();
See index.html and benchmarks.ts for website and js code examples
Results
Results show a statistics table, a plot with various statistics (quartiles, median, mean, trimmed mean) and a regression plot.
The correlation in the table should be almost 1, if it's less than 0.99 a ⚠️ sign is shown. If correlation is less than 0.9 a ☠ sign is shown because results are not valid.
Based on Maplibre's benchmarking tool