array read order

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var COLS = 100;
    var ROWS = 100;
   
    var newArr = function() {
        var arr = new Array( COLS*ROWS )
        for ( var i = 0; i < arr.length; i++ ) {
            arr[i] = (i*3)%29;
        }
        return arr;
    }
};
</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
non-linear
var arr = newArr()

for ( var i = 0; i < ROWS; i++ ) {
    for ( var j = 0; j < COLS; j++ ) {
        arr[j*ROWS + i] += 2;
    }
}
pending…
linear

var arr = newArr()

for ( var j = 0; j < COLS; j++ ) {
    for ( var i = 0; i < ROWS; i++ ) {
        arr[j*ROWS + i] += 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