nbm

0.0.4 • Public • Published

Benchmark utility for nodejs

To install

$ npm install nbm

Usage

Initialize new benchmark object.

var nbm = require('nbm');
var benchmark = nbm.benchmark();

You can add precision (qty of decimals)

var benchmark = nbm.benchmark({
  'precision': 4 // will output 4 decimals
});

Place start() at the top of the script.

benchmark.start('Some description');

Place end() at the bottom of the script, or for async functions in the callback.

benchmark.end('Some description');
 
// async
 
setTimeout(function() {
   benchmark.end('some description');
  }, 1000);

Example

var nbm = require('./index.js');
 
var benchmark = nbm.benchmark({
  precision: 6
});
 
// Simple example
// Place start() at the top of your script.
benchmark.start('database connection benchmark');
 
someAsyncRequest();
 
function someAsyncRequest (cb) {
  setTimeout(function() {
   benchmark.end('database connection end'); // place end() in the callback of your function.
  }, 1000);
}

Package Sidebar

Install

npm i nbm

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • anthonydm