Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
/benchmark.jsPublic archive

A benchmarking library. As used on jsPerf.com.

License

NotificationsYou must be signed in to change notification settings

bestiejs/benchmark.js

Repository files navigation

Arobust benchmarking library that supports high-resolution timers & returns statistically significant results. As seen onjsPerf.

Documentation

Download

Installation

Benchmark.js’ only hard dependency islodash.Includeplatform.js to populateBenchmark.platform.

In a browser:

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

Optionally, enable Chrome’s microsecond timer by using thecommand line switch:

  --enable-benchmarking

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:

varBenchmark=require('benchmark');

Optionally, use themicrotime module by Wade Simmons:

npm install microtime

Usage example:

varsuite=newBenchmark.Suite;// add testssuite.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 46-47, Firefox 42-43, IE 9-11, MS Edge 13, Safari 8-9, Node.js 0.8.28, 0.10.41, 0.12.9, 4.2.4, & 5.3.0, & PhantomJS 1.9.8.

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.


[8]ページ先頭

©2009-2025 Movatter.jp