GithubHelp home page GithubHelp logo

ncb000gt / benchmark.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bestiejs/benchmark.js

2.0 3.0 0.0 3.33 MB

A benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results. As used on jsPerf.com.

Home Page: http://benchmarkjs.com/

License: Other

benchmark.js's Introduction

Benchmark.js v1.0.0-pre

A robust benchmarking library that works on nearly all JavaScript platforms1, supports high-resolution timers, and returns statistically significant results. As seen on jsPerf.

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, and plenty of documentation.

Documentation

The documentation for Benchmark.js can be viewed here: http://benchmarkjs.com/docs

For a list of upcoming features, check out our roadmap.

Installation and usage

In a browser or Adobe AIR:

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

Optionally, expose Java’s nanosecond timer by adding the nano applet to the <body>:

<applet code="nano" archive="nano.jar"></applet>

Or enable Chrome’s microsecond timer by using the command line switch:

--enable-benchmarking

Via npm:

npm install benchmark

In Node.js and RingoJS v0.8.0+:

var Benchmark = require('benchmark');

Optionally, use the microtime module by Wade Simmons:

npm install microtime

In Narwhal and RingoJS v0.7.0-:

var Benchmark = require('benchmark').Benchmark;

In Rhino:

load('benchmark.js');

In an AMD loader like RequireJS:

require({
  'paths': {
    'benchmark': 'path/to/benchmark'
  }
},
['benchmark'], function(Benchmark) {
  console.log(Benchmark.version);
});

// or with platform.js
// https://github.com/bestiejs/platform.js
require({
  'paths': {
    'benchmark': 'path/to/benchmark',
    'platform': 'path/to/platform'
  }
},
['benchmark', 'platform'], function(Benchmark, platform) {
  Benchmark.platform = platform;
  console.log(Benchmark.platform.name);
});

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').pluck('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

Cloning this repo

To clone this repository including all submodules, using Git 1.6.5 or later:

git clone --recursive https://github.com/bestiejs/benchmark.js.git
cd benchmark.js

For older Git versions, just use:

git clone https://github.com/bestiejs/benchmark.js.git
cd benchmark.js
git submodule update --init

Feel free to fork and send pull requests if you see improvements!

Footnotes

  1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.

Authors

Contributors

benchmark.js's People

Contributors

jdalton avatar mathiasbynens avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.