@clevernature/benchmark-regression

1.0.1 • Public • Published

Benchmark Regression NPM version Linux Build Status

Generates performance regression tests using benchmarkjs.

Install

npm install --save-dev @clevernature/benchmark-regression

Code

const createRegressionBenchmark = require('@clevernature/benchmark-regression');
const currentClient = require('..');

const benchmarks = createRegressionBenchmark(currentClient, ['prom-client@11.1.2']);

benchmarks.suite('registry', (suite) => {
    suite.add(
        'getMetricsAsJSON',
        (client, { registry }) => registry.getMetricsAsJSON(),
        { setup }
    );
    suite.add(
        'metrics',
        (client, { registry }) => registry.metrics(),
        { setup }
    );
});

benchmarks.add(
    'histogram#observe',
    (client, { histogram }) => histogram.observe(1, { a: 1, b: 1 }),
    { setup }
);

benchmarks.run().catch(err => {
    console.error(err.stack);
    process.exit(1);
});

function setup(client) {
    const registry = new client.Registry();

    const histogram = new client.Histogram({
        name: 'histogram',
        help: 'histogram',
        labelNames: ['a', 'b'],
        registers: [registry]
    });

    histogram.observe(1, { a: 1, b: 1 });

    return {registry, histogram};
}

Results

Benchmark Results

Readme

Keywords

Package Sidebar

Install

npm i @clevernature/benchmark-regression

Weekly Downloads

68

Version

1.0.1

License

MIT

Unpacked Size

26.7 kB

Total Files

9

Last publish

Collaborators

  • nowells