@kwiwk/bench
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

bench

A simple benchmarking utility.

Build Status Coveralls github npm npm

Kwiwk Logo

Table Of Contents

Description

View examples here

Getting Started

  • Install Node v8 LTS here.

Documentation

Example: Testing promisified setTimeout.

// Import Benchmarking utility
import { Bench } from "@kwiwk/bench";

// Some iterable helper utilities
import { itMap, itRange, itStutter } from "./it_utils";

// Create a new Bench utility.
const bench = new Bench({
    inputs: itMap(itRange(0, 100), i => ({ label: `${i}`, value: i }))
});

// Time our test function
bench.addTestAsync("delayMs", async input => delayMs(input));

// Output difference between result and expected result.
bench.addRaw("diff", (input, results) => {
    return (results["delayMs"] - input).toString();
});

// Run the benchmarking.
bench.run("./delay.csv");

// Function under test
async function delayMs(ms: number): Promise<void> {
    return new Promise<void>((resolve, reject) => setTimeout(resolve, ms));
}

View the API docs here.

View the coverage report here.

License

View the license here.

Changelog

View the changelog here.

Readme

Keywords

none

Package Sidebar

Install

npm i @kwiwk/bench

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

117 kB

Total Files

17

Last publish

Collaborators

  • russleyshaw