loop-with-array-as-variables

JavaScript performance comparison

Revision 4 of this test case created by

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
plain variables
(function() {
  var m = 0;
  for (var n = 0; n < 10000000; n++) m += n;
})();
pending…
Int32Array
(function() {
  var gpr = new Int32Array(32);
  for (gpr[0] = 0; gpr[0] < 10000000; gpr[0]++) {
    gpr[1] += gpr[0];
  }
})();
pending…
Int32Array inside object
(function() {
  var state = {
    gpr: new Int32Array(32)
  };
  for (state.gpr[0] = 0; state.gpr[0] < 10000000; state.gpr[0]++) {
    state.gpr[1] += state.gpr[0];
  }
})();
pending…
Float64Array inside object
(function() {
  var state = {
    gpr: new Float64Array(32)
  };
  for (state.gpr[0] = 0; state.gpr[0] < 10000000; state.gpr[0]++) {
    state.gpr[1] += state.gpr[0];
  }
})();
pending…
Uint32Array
(function() {
  var gpr = new Uint32Array(32);
  for (gpr[0] = 0; gpr[0] < 10000000; gpr[0]++) {
    gpr[1] += gpr[0];
  }
})();
pending…
Float32Array inside object
(function() {
  var state = {
    gpr: new Float32Array(32)
  };
  for (state.gpr[0] = 0; state.gpr[0] < 10000000; state.gpr[0]++) {
    state.gpr[1] += state.gpr[0];
  }
})();
pending…
plain variables inside object
(function() {
  var state = { n: 0, m: 0 };
  for (state.n = 0; state.n < 10000000; state.n++) state.m += state.n;
})();
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