0.1.0 • Published 3 years ago

node-microbenchmark v0.1.0

Weekly downloads
3
License
MIT
Repository
-
Last release
3 years ago

node-microbenchmark

npm version

A micro benchmarking library inspired from google-benchmark

Features available:

  • Benchmarking synchronous functions
  • Benchmarking of asynchronous functions
    • Support for Promises
  • High precision benchmark (upto nanoseconds precision)

Benchmarking of synchronous functions

const { benchmark, show } = require('node-microbenchmark');

const slowFn = () => {
    for (var i = 0; i < 1e4; ++i);
}

const fastFn = () => {}

benchmark(slowFn);
benchmark(fastFn);

show();

Benchmarking of asynchronous functions

const benchmark = require('../index');

const slowTimer = () => new Promise(res => setTimeout(res, 200));
const fastTimer = () => new Promise(res => setTimeout(res, 50));

const fn = async () => {
  await benchmark.benchmarkPromise(slowTimer);
  await benchmark.benchmarkPromise(fastTimer);
  benchmark.show();
};

fn();

node-microbenchmark

Future enhancements

  • Benchmark async code like promises.

Author

0.1.0

3 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago