# benchmark.js **Repository Path**: shanghai-leisurely-network_0/benchmark.js ## Basic Information - **Project Name**: benchmark.js - **Description**: A benchmarking library. As used on jsPerf.com. - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-01-09 - **Last Updated**: 2024-06-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Benchmark.js v2.1.4 A [robust](https://mathiasbynens.be/notes/javascript-benchmarking "Bulletproof JavaScript benchmarks") benchmarking library that supports high-resolution timers & returns statistically significant results. As seen on [jsPerf](https://jsperf.com/). ## Documentation * [API Documentation](https://benchmarkjs.com/docs) ## Download * [Development source](https://raw.githubusercontent.com/bestiejs/benchmark.js/2.1.4/benchmark.js) ## Installation Benchmark.js’ only hard dependency is [lodash](https://lodash.com/). Include [platform.js](https://mths.be/platform) to populate [Benchmark.platform](https://benchmarkjs.com/docs#platform). In a browser: ```html ``` In an AMD loader: ```js require({ 'paths': { 'benchmark': 'path/to/benchmark', 'lodash': 'path/to/lodash', 'platform': 'path/to/platform' } }, ['benchmark'], function(Benchmark) {/*…*/}); ``` Using npm: ```shell $ npm i --save benchmark ``` In Node.js: ```js var Benchmark = require('benchmark'); ``` Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons: ```shell npm i --save microtime ``` Usage example: ```js 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.