branch-prediction

JavaScript performance comparison

Revision 2 of this test case created by jdalton

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var o = {
    ConditionTrue: true,
    ConditionFalse: false,
    k: 0,
  
    priTrue: function() {
      if (this.ConditionTrue) {
        return true;
      } else {
        return false;
      }
    },
    priFalse: function() {
      if (this.ConditionFalse) {
        return true;
      } else {
        return false;
      }
    },
    priMixed: function() {
      var ConditionX = ++this.k % 2;
      if (ConditionX) {
        return true;
      } else {
        return false;
      }
    }
  };

};
</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
method 1
var r = o.priTrue();
pending…
method 2
var r = o.priFalse();
pending…
method 3
var r = o.priMixed();
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.

0 Comments