0.1.1 • Published 3 years ago

@webmangler/benchmarking v0.1.1

Weekly downloads
-
License
Unlicense
Repository
github
Last release
3 years ago

WebMangler Benchmarking Utilities

NPM Package

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);
  });
});