array vs uint32array (v7)

Revision 7 of this benchmark created on


Description

Switched from Uint16Array to Uint32Array, pre-allocated the Array object, ensured c does a set so it does not get optimized out, put the global variable "total" into a local variable "t" for executing the tests, raised the total from 1000 to 50000, changed to Math.floor(.5+i) to generate a floating point number that has not already been converted to integer, added "set Array with bitmask" test

Setup

var total = 50000;
    var a = new Array(total);
    var b = new Uint32Array(total);
    var y;
    var c = function (x) {
      y = x;
    };
    for(var i=0; i<total; i++){
    a[i] = i;
    b[i] = i;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
access array
for(var i=0,t=total; i<t; i++){
c(a[i]);
}
ready
access Uint32array
for(var i=0,t=total; i<t; i++){
c(b[i]);
}
ready
set Array
for(var i=0,t=total; i<t; i++){
c(a[i] = Math.floor(.5+i));
}
ready
set Uint32array
for(var i=0,t=total; i<t; i++){
c(b[i] = Math.floor(.5+i));
}

 
ready
set Array with bitmask
for(var i=0,t=total; i<t; i++){
c(a[i] = Math.floor(.5+i) & 0xFFFFFFFF);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.