branch-prediction

JavaScript performance comparison

Revision 2 of this test case created by jdalton

Info

Modified micro-benchmark with different outcome.

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 unknown unknown
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. Here’s a list of current revisions for this page:

0 comments

Add a comment