Benchmark.js test page

JavaScript performance comparison

Test case created by Mathias Bynens and last updated

Info

This is just a test document for Benchmark.js.

Preparation code

<div>Lorem ipsum</div>
<script>
  var arr = [1, 5, 4, 2, 3];

  function init() {
    window.console && console.log('init called');
  }
</script>
<script>
Benchmark.prototype.setup = function() {
    window.foo = 42;
    var x = arr;
};

Benchmark.prototype.teardown = function() {
    window.foo = 24;
};
</script>

Preparation code output

Lorem ipsum

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Normal
x.sort(function(a, b) {
  return a - b;
});
pending…
Exit Early
x.sort(function(a, b) {
  return a - b;
});
return;
pending…
Async
// async test
setTimeout(function() {
  deferred.resolve();
}, 10);
pending…
Comments
// comments at start
x.reverse().sort(function(a, b) {
  return a - b;
});
// comments at end
pending…
TypeError
x.foo(); // unknown method
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment