arnaucube
arnaucube/raspberryGPIOhtmlserverPublic Self-hosted repository
raspberryGPIOhtmlserver/node_modules/benchmark/README.md
node_modules/benchmark/README.mdRaw
  1# Benchmark.js <sup>v1.0.0</sup>
  2
  3A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
  4
  5## BestieJS
  6
  7Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
  8
  9## Documentation
 10
 11The documentation for Benchmark.js can be viewed here: <http://benchmarkjs.com/docs>
 12
 13For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).
 14
 15## Support
 16
 17Benchmark.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
 18
 19## Installation and usage
 20
 21In a browser or Adobe AIR:
 22
 23~~~ html
 24<script src="benchmark.js"></script>
 25~~~
 26
 27Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the `<body>`:
 28
 29~~~ html
 30<applet code="nano" archive="nano.jar"></applet>
 31~~~
 32
 33Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking):
 34
 35    --enable-benchmarking
 36
 37Via [npm](http://npmjs.org/):
 38
 39~~~ bash
 40npm install benchmark
 41~~~
 42
 43In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
 44
 45~~~ js
 46var Benchmark = require('benchmark');
 47~~~
 48
 49Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons:
 50
 51~~~ bash
 52npm install microtime
 53~~~
 54
 55In [RingoJS v0.7.0-](http://ringojs.org/):
 56
 57~~~ js
 58var Benchmark = require('benchmark').Benchmark;
 59~~~
 60
 61In [Rhino](http://www.mozilla.org/rhino/):
 62
 63~~~ js
 64load('benchmark.js');
 65~~~
 66
 67In an AMD loader like [RequireJS](http://requirejs.org/):
 68
 69~~~ js
 70require({
 71  'paths': {
 72    'benchmark': 'path/to/benchmark'
 73  }
 74},
 75['benchmark'], function(Benchmark) {
 76  console.log(Benchmark.version);
 77});
 78
 79// or with platform.js
 80// https://github.com/bestiejs/platform.js
 81require({
 82  'paths': {
 83    'benchmark': 'path/to/benchmark',
 84    'platform': 'path/to/platform'
 85  }
 86},
 87['benchmark', 'platform'], function(Benchmark, platform) {
 88  Benchmark.platform = platform;
 89  console.log(Benchmark.platform.name);
 90});
 91~~~
 92
 93Usage example:
 94
 95~~~ js
 96var suite = new Benchmark.Suite;
 97
 98// add tests
 99suite.add('RegExp#test', function() {
100  /o/.test('Hello World!');
101})
102.add('String#indexOf', function() {
103  'Hello World!'.indexOf('o') > -1;
104})
105// add listeners
106.on('cycle', function(event) {
107  console.log(String(event.target));
108})
109.on('complete', function() {
110  console.log('Fastest is ' + this.filter('fastest').pluck('name'));
111})
112// run async
113.run({ 'async': true });
114
115// logs:
116// > RegExp#test x 4,161,532 +-0.99% (59 cycles)
117// > String#indexOf x 6,139,623 +-1.00% (131 cycles)
118// > Fastest is String#indexOf
119~~~
120
121## Authors
122
123* [Mathias Bynens](http://mathiasbynens.be/)
124  [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter")
125* [John-David Dalton](http://allyoucanleet.com/)
126  [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter")
127
128## Contributors
129
130* [Kit Cambridge](http://kitcambridge.github.com/)
131  [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter")