JavaScript performance comparison

Revision 3 of this test case created by Erick Ribeiro

Preparation code

<button id="button1">
  Click here
Benchmark.prototype.setup = function() {
    function test2() {
      var x = 1;
      var y = 2;
      alert(x + y);

Benchmark.prototype.teardown = function() {
    document.getElementById("button1").onclick = function(){};

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
function inside addEventListener
document.getElementById("button1").addEventListener("click", function() {
  var x = 1;
  var y = 2;
  alert(x + y);
}, false);
function outside addEventListener
document.getElementById("button1").addEventListener("click", test2, false);

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment