bnch

A very simple (yet another) node benchmark utility

npm install bnch
12 downloads in the last month

bnch

Node.js benchmark in the console

Note: this project is pretty young and the results are pretty varied atm. See TODO.

Installation

npm install bnch

Usage:

Create a new file called mybenchmark.js

var bnch = require('bnch');

var array = new Array(65536);
array[65500] = 'mom';

var suite = bnch();

// optional, if you want to specify some preparation before each run
suite.beforeEach(function() {
    // return the value to be used in the benchmark
    return array.slice(0);
});

suite.add("Array#indexOf", function(array) {
    array.indexOf('mom');
});

suite.add("manual search", function(array) {
    for (var i = 0, l = array.length; i < l; i++) {
        if (array[i] === 'mom') {
            break;
        }
    }
});

And run your file using

node mybenchmark.js

And the output will look like this:

benchmark results

Todo

  • Isolate tests better so the results are not as varied
  • Possibly support async tests
  • Adjust sample size depending on the time each thing takes to run

License

MIT

npm loves you