benchmark
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

benchmark

A benchmarking library that supports high-resolution timers & returns statistically significant results.

2.1.4  •  Published 3 years ago  •  by bestiejs  •  MIT License

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:

<script src="lodash.js"></script>
<script src="platform.js"></script>
<script src="benchmark.js"></script>

In an AMD loader:

require({
  'paths': {
    'benchmark': 'path/to/benchmark',
    'lodash': 'path/to/lodash',
    'platform': 'path/to/platform'
  }
},
['benchmark'], function(Benchmark) {/*…*/});

Using npm:

$ npm i --save benchmark

In Node.js:

var Benchmark = require('benchmark');

Optionally, use the microtime module by Wade Simmons:

npm i --save microtime

Usage example:

var suite = new Benchmark.Suite;

// add tests
suite.add('RegExp#test', function() {
  /o/.test('Hello World!');
})
.add('String#indexOf', function() {
  'Hello World!'.indexOf('o') > -1;
})
// add listeners
.on('cycle', function(event) {
  console.log(String(event.target));
})
.on('complete', function() {
  console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });

// 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.

Popularity

Weekly Downloads
138.6K
Stars
4.3K

Maintenance

Development

Last ver 3 years ago
Created 9 years ago
Last commit 1 year ago
4 days between commits

Technology

Node version: 7.7.2
0 unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

23 contributors
jdalton
Maintainer, 865 commits, 49 merges, 11 PRs
Works at Salesforce
Mathias Bynens
Maintainer, 119 commits, 3 PRs
Works at Google
Benjamin Tan
Maintainer, 10 commits, 10 PRs
Kit Goncharov
5 commits
Daniel Ruf
4 commits, 5 PRs
Works at bitExpert
Greenkeeper
2 commits, 11 PRs
Works at greenkeeperio

Tags

benchmark
performance
speed
Ready for the next level?
Join Devstore's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
© 2019 Devstore, Inc.
Devstore helps developers find and use open-source packages, so they can focus on building amazing things