bnch
v1.0.16
Published
A very simple (yet another) node benchmark utility
Downloads
9
Maintainers
Readme
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:
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