native vs typed js array speed

JavaScript performance comparison

Revision 63 of this test case created by Kiren

Preparation code

<script>
  var arraySize = 2000;

  var nativeArray;
  var int32Array;
  var float32Array;
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var sum = 0;
  

};
</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 Write
nativeArray = new Array(arraySize);
for (var i = 0; i < arraySize; ++i) {
  nativeArray[i] = i;
}
pending…
Int32 Write
int32Array = new Int32Array(arraySize);
for (var i = 0; i < arraySize; ++i) {
  int32Array[i] = i;
}
pending…
Float32 Write
float32Array = new Float32Array(arraySize);
for (var i = 0; i < arraySize; ++i) {
  float32Array[i] = i;
}
pending…
Native Read
for (var i = 0; i < arraySize; ++i) {
  sum += nativeArray[i];
}
pending…
Int32 Read
for (var i = 0; i < arraySize; ++i) {
  sum += int32Array[i];
}
pending…
Float32 Read
for (var i = 0; i < arraySize; ++i) {
  sum += float32Array[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