native vs typed js array speed

JavaScript performance comparison

Revision 50 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
    var arraySize = 1000;
    
    var typedArray = new Int32Array(arraySize);
    var nativeArray = [];
  var sum = 0;
  for (var i = 0; i<arraySize; i++) {
   nativeArray[i] = i+2;
   typedArray[i] = i+2;
  }

};
</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
Native Read up
for (var i = 0; i<arraySize; i++) {
 sum += nativeArray[i];
}
pending…
Native Read down
for (var i = arraySize-1; i>-1; i--) {
 sum += nativeArray[i];
}
pending…
Typed Read up
for (var i = 0; i<arraySize; i++) {
 sum += typedArray[i];
}
pending…
Typed Read down
for (var i = arraySize-1; i>-1; i--) {
 sum += typedArray[i];
}
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