@webmangler/benchmarking
v0.1.1
Published
WebMangler benchmarking utilities
Downloads
1
Readme
WebMangler Benchmarking Utilities
A collection of benchmarking utilities for WebMangler packages and plugins.
Usage
Install @webmangler/benchmarking
, e.g.:
$ npm install @webmangler/benchmarking --save-dev
Import and use the benchmarking utilities in your benchmark, e.g.:
// my-module.bench.ts
import { benchmarkFn, getRuntimeBudget } from "@webmangler/benchmarking";
import slowFunction from "../my-module";
suite("My benchmark", function() {
test("normal usage", function() {
const runtimeBudget = getRuntimeBudget(5); // In milliseconds
const benchmarkResult = benchmarkFn({
fn: () => slowFunction("foo", "bar"),
});
expect(benchmarkResult.medianDuration).to.be.below(runtimeBudget);
});
});