If VS short circuiting

JavaScript performance comparison

Test case created by nallar

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var falseThing = false;
    var trueThing = true;
    var i = 0;
   
    function uselessFunction() {
      i = 0;
    }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Short circuiting
falseThing && uselessFunction();
falseThing || uselessFunction();
trueThing && uselessFunction();
trueThing || uselessFunction();
pending…
if
if (falseThing) uselessFunction();
if (!falseThing) uselessFunction();
if (trueThing) uselessFunction();
if (!trueThing) uselessFunction();
pending…
Stupid short-circuiting
falseThing && uselessFunction();
!falseThing && uselessFunction();
trueThing && uselessFunction();
!trueThing && uselessFunction();
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment