Benchmark.js v2.1.4
A robust benchmarking library that supports high-resolution timers & returns statistically significant results. As seen on jsPerf.
Documentation
Download
Installation
Benchmark.js’ only hard dependency is lodash. Include platform.js to populate Benchmark.platform.
In a browser:
In an AMD loader:
;
Using npm:
$ npm i --save benchmark
In Node.js:
var Benchmark = ;
Optionally, use the microtime module by Wade Simmons:
npm i --save microtime
Usage example:
var suite = ; // add testssuite// add listeners// run async; // logs:// => RegExp#test x 4,161,532 +-0.99% (59 cycles)// => String#indexOf x 6,139,623 +-1.00% (131 cycles)// => Fastest is String#indexOf
Support
Tested in Chrome 54-55, Firefox 49-50, IE 11, Edge 14, Safari 9-10, Node.js 6-7, & PhantomJS 2.1.1.
BestieJS
Benchmark.js is part of the BestieJS “Best in Class” module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, & plenty of documentation.