Multi For Loop

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = [],
      b = [],
      len = 100;
   
    for (var i = 0; i < len; i++) {
      a[i] = Math.random();
      b[i] = Math.random();
    }
};
</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
Single
for (var i = 0; i < len; i++) {
  a[i] *= b[i];
}
pending…
Expand Two
for (var i = 0; i < len; i += 2) {
  a[i] *= b[i];
  a[i + 1] *= b[i + 1];
}
pending…
Expand Five
for (var i = 0; i < len; i += 5) {
  a[i] *= b[i];
  a[i + 1] *= b[i + 1];
  a[i + 2] *= b[i + 2];
  a[i + 3] *= b[i + 3];
  a[i + 4] *= b[i + 4];
}
pending…
Expand Ten
for (var i = 0; i < len; i += 10) {
  a[i] *= b[i];
  a[i + 1] *= b[i + 1];
  a[i + 2] *= b[i + 2];
  a[i + 3] *= b[i + 3];
  a[i + 4] *= b[i + 4];
  a[i + 5] *= b[i + 5];
  a[i + 6] *= b[i + 6];
  a[i + 7] *= b[i + 7];
  a[i + 8] *= b[i + 8];
  a[i + 9] *= b[i + 9];
}
pending…
No Loop
a[0] *= b[0];
a[1] *= b[1];
a[2] *= b[2];
a[3] *= b[3];
a[4] *= b[4];
a[5] *= b[5];
a[6] *= b[6];
a[7] *= b[7];
a[8] *= b[8];
a[9] *= b[9];
a[10] *= b[10];
a[11] *= b[11];
a[12] *= b[12];
a[13] *= b[13];
a[14] *= b[14];
a[15] *= b[15];
a[16] *= b[16];
a[17] *= b[17];
a[18] *= b[18];
a[19] *= b[19];
a[20] *= b[20];
a[21] *= b[21];
a[22] *= b[22];
a[23] *= b[23];
a[24] *= b[24];
a[25] *= b[25];
a[26] *= b[26];
a[27] *= b[27];
a[28] *= b[28];
a[29] *= b[29];
a[30] *= b[30];
a[31] *= b[31];
a[32] *= b[32];
a[33] *= b[33];
a[34] *= b[34];
a[35] *= b[35];
a[36] *= b[36];
a[37] *= b[37];
a[38] *= b[38];
a[39] *= b[39];
a[40] *= b[40];
a[41] *= b[41];
a[42] *= b[42];
a[43] *= b[43];
a[44] *= b[44];
a[45] *= b[45];
a[46] *= b[46];
a[47] *= b[47];
a[48] *= b[48];
a[49] *= b[49];
a[50] *= b[50];
a[51] *= b[51];
a[52] *= b[52];
a[53] *= b[53];
a[54] *= b[54];
a[55] *= b[55];
a[56] *= b[56];
a[57] *= b[57];
a[58] *= b[58];
a[59] *= b[59];
a[60] *= b[60];
a[61] *= b[61];
a[62] *= b[62];
a[63] *= b[63];
a[64] *= b[64];
a[65] *= b[65];
a[66] *= b[66];
a[67] *= b[67];
a[68] *= b[68];
a[69] *= b[69];
a[70] *= b[70];
a[71] *= b[71];
a[72] *= b[72];
a[73] *= b[73];
a[74] *= b[74];
a[75] *= b[75];
a[76] *= b[76];
a[77] *= b[77];
a[78] *= b[78];
a[79] *= b[79];
a[80] *= b[80];
a[81] *= b[81];
a[82] *= b[82];
a[83] *= b[83];
a[84] *= b[84];
a[85] *= b[85];
a[86] *= b[86];
a[87] *= b[87];
a[88] *= b[88];
a[89] *= b[89];
a[90] *= b[90];
a[91] *= b[91];
a[92] *= b[92];
a[93] *= b[93];
a[94] *= b[94];
a[95] *= b[95];
a[96] *= b[96];
a[97] *= b[97];
a[98] *= b[98];
a[99] *= b[99];
 
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