2D Array of Numbers

JavaScript performance comparison

Revision 2 of this test case created by Ken

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var classic = [
      [1, 2, 3],
      [1, 2, 3],
      [1, 2, 3]
  ];
  
  var clTyped = [
      new Int8Array(3),
      new Int8Array(3),
      new Int8Array(3)
  ];
  
  var flat = [1, 2, 3, 1, 2, 3, 1, 2, 3];
  var flTyped = new Int8Array(flat.length);
  
  var width = 3;

};
</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
Classic
var v = classic[1][1];
classic[2][2] = 255;
pending…
Flat
var v = flat[1 * width + 1];
flat[2 * width + 2] = 255;
pending…
Classic Typed
var v = clTyped[1][1];
clTyped[2][2] = 255;
pending…
Flat Typed
var v = flTyped[1 * width + 1];
flTyped[2 * width + 2] = 255;
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