truth

JavaScript performance comparison

Revision 2 of this test case created by John-David Dalton

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var i = 0;
  var one = 1;
  var zero = 0;
  var bool = true;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
if (bool) i++
if (bool) i++
pending…
if (!!bool) i++
if (!!bool) i++
pending…
if (!0) i++
if (!0) i++
pending…
if (true) i++
if (true) i++
pending…
if (false) i++
if (false) {} i++
pending…
if (1) i++
if (1) i++
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.

2 Comments

Malte Ubl commented :

Don't actually understand why declaring vars in a setup function should be visible in the tests?

Mathias Bynens commented :

It avoids the scope lookup for the variable; so tests that use variables don’t get penalized. Test results will be even more accurate this way.