Array Speedtest

JavaScript performance comparison

Test case created

Info

Coordinates-Array Speedtest

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var w = 1000,
        h = 1000;
    var arr1 = [];
    var arr2 = [];
    var arr3 = [];
   
    var i = 0,
        ii = 0;
    for (var y = 0; y < h; ++y) {
      arr1[y] = [];
      for (var x = 0; x < w; ++x) {
        i = x + (y * w);
        ii = i * 3;
        arr1[y][x] = [1, 1, 1];
        arr2[i] = [1, 1, 1];
        arr3[ii] = 1;
        arr3[ii + 1] = 1;
        arr3[ii + 2] = 1;
      }
    }
};
</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
2D Array
for (var y = 0; y < h; ++y) {
  for (var x = 0; x < w; ++x) {
    arr1[y][x] = [0, 1, 2];
  }
}
pending…
1D Array
var i = 0;
for (var y = 0; y < h; ++y) {
  for (var x = 0; x < w; ++x) {
    i = x + (y * w);
    arr2[i] = [0, 1, 2];
  }
}
pending…
1D Array - Big Index
var i = 0;
for (var y = 0; y < h; ++y) {
  for (var x = 0; x < w; ++x) {
    i = (x + (y * w)) * 3;
    arr3[i] = 0;
    arr3[i + 1] = 1;
    arr3[i + 2] = 2;
  }
}
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