Row wise vs column wise array access

JavaScript performance comparison

Test case created by Shreyas Subramaniam

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var N = 1000;
    var values = [];
    for (var i=0;i<1000;i++){
     values.push([]);
    }
};
</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
row wise

  var i, j, r;

    for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
        values[i][j] = 42;
      }
    }
 
pending…
column-wise
  var i, j, r;
    for (j = 0; j < N; j++) {
      for (i = 0; i < N; i++) {
        values[i][j] = 42;
      }
    }
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