1.0.16 • Published 2 years ago

bnch v1.0.16

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

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

1.0.16

2 years ago

1.0.15

2 years ago

1.0.11

2 years ago

1.0.13

2 years ago

1.0.9

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago