native vs typed js array speed (v12)

Revision 12 of this benchmark created on


Preparation HTML

<script>
  var arraySize = 10000;
  
  var typedArray = new Int32Array(arraySize);
  var nativeArray = new Array(arraySize);
</script>

Setup

var sum = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
Native array
//Write
for (var i = arraySize-1; i; i--) {
 nativeArray[i] = i;
}

//Read
for (var i = arraySize-1; i; i--) {
 sum += nativeArray[i];
}
ready
Typed array
//Write
for (var i = arraySize-1; i; i--) {
 typedArray[i] = i;
}

//Read
for (var i = arraySize-1; i; i--) {
 sum += nativeArray[i];
}
ready

Revisions

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