bnch
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

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

Package Sidebar

Install

npm i bnch

Weekly Downloads

3

Version

1.0.16

License

MIT

Unpacked Size

9.92 kB

Total Files

6

Last publish

Collaborators

  • arnorhs