# LoopWithIfElse

## JavaScript performance comparison

Revision 2 of this test case created

## Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
WithIfElse
``var arr = [1, 2, 3, 4];var xmin = Number.POSITIVE_INFINITY;var xmax = Number.NEGTIVE_INIFINITY;var ymin = Number.POSITIVE_INFINITY;var ymax = Number.NEGTIVE_INIFINITY;for (var i=0; i<arr.length; i+=2){    var x = arr[i];    var y = arr[i+1];    if (x < xmin){        xmin = x;    } else if (x > xmax) {        xmax = x;    }    if (y < ymin){        ymin = y;    } else if (y > ymax) {        ymax = y;    }}``
pending…
WithoutIfElse
``var arr = [1, 2, 3, 4];var xmin = Number.POSITIVE_INFINITY;var xmax = Number.NEGTIVE_INIFINITY;var ymin = Number.POSITIVE_INFINITY;var ymax = Number.NEGTIVE_INIFINITY;for (var i=0; i<arr.length; i+=2){    var x = arr[i];    var y = arr[i+1];    if (x < xmin)  xmin = x;    if (x > xmax)  xmax = x;    if (y < ymin)  ymin = y;    if (y > ymax)  ymax = y;}``
pending…
DifferentInitialValues
``var arr = [1, 2, 3, 4];var xmin = Number.MAX_VALUE;var xmax = -Number.MAX_VALUE;var ymin = Number.MAX_VALUE;var ymax = -Number.MAX_VALUE;for (var i=0; i< arr.length; i+=2){    var x = arr[i];    var y = arr[i+1];    if (x < xmin){        xmin = x;    } else if (x > xmax) {        xmax = x;    }    if (y < ymin){        ymin = y;    } else if (y > ymax) {        ymax = y;    }}``
pending…
WithLittleChange
``var arr = [1, 2, 3, 4];var xmin = Number.MAX_VALUE;var xmax = -Number.MAX_VALUE;var ymin = Number.MAX_VALUE;var ymax = -Number.MAX_VALUE;for (var i=0, len = arr.length; i< len; i+=2){    var x = arr[i];    var y = arr[i+1];    if (x < xmin){        xmin = x;    } else if (x > xmax) {        xmax = x;    }    if (y < ymin){        ymin = y;    } else if (y > ymax) {        ymax = y;    }}``
pending…
``var arr = [1, 2, 3, 4];var xmin = Number.MAX_VALUE;var xmax = -Number.MAX_VALUE;var ymin = Number.MAX_VALUE;var ymax = -Number.MAX_VALUE;for (var i=0, len = arr.length/2; i< len; i++){    var x = arr[i*2];    var y = arr[i*2+1];    if (x < xmin){        xmin = x;    } else if (x > xmax) {        xmax = x;    }    if (y < ymin){        ymin = y;    } else if (y > ymax) {        ymax = y;    }}``
pending…

## 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: