JSPM

node-microbenchmark

0.1.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 17
    • Score
      100M100P100Q22545F
    • License MIT

    NodeJS micro benchmarking library

    Package Exports

    • node-microbenchmark

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-microbenchmark) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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