This package has been deprecated

Author message:

Migrated to https://www.npmjs.com/package/toofast

@smikhalevski/perf-test
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

perf-test

The Node.js performance testing tool.

npm install --save-dev @smikhalevski/perf-test

⚠️ API documentation is available here.

Usage

Measure performance of a callback:

const {test} = require('@smikhalevski/perf-test');

function callback() {
  // The code you want to test goes here
}

test('My test', callback, {timeout: 3000});
// stdout: "My test 7,331,041.16 ops/sec ± 0.19%"

Measure performance of a callback across a population of values:

const {valueTest} = require('@smikhalevski/perf-test');

function callback(value) {
  // value is 1, 2 or 3 
  // The code you want to test goes here
}

valueTest([1, 2, 3], 'My test', callback, {timeout: 3000});
// stdout: "My test 7,331,041.16 ops/sec ± 0.19%"

Get programmatic access to the test result statistics:

const {createHistogram, cycle} = require('@smikhalevski/perf-test');

function callback() {
  // The code you want to test goes here
}

const histogram = createHistogram();

cycle(callback, histogram, {timeout: 3000});

histogram.getHz(); // → 7331041.16

Readme

Keywords

Package Sidebar

Install

npm i @smikhalevski/perf-test

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

19.5 kB

Total Files

16

Last publish

Collaborators

  • smikhalevski