@kwiwk/bench
v1.0.0
Published
Benchmarking utilities.
Downloads
2
Readme
bench
A simple benchmarking utility.
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.