Typed array iteration (v2)

Revision 2 of this benchmark created by vjeux on


Description

The test is more useful when the values are already set. On chrome, typed arrays are slower than normal arrays in this case!

Preparation HTML

<script>
  var classic = new Array(500);
  
  var unfixed = new Int8Array(); // Don't do this
  var fixed = new Int8Array(500);
  
  for (var i = 0; i < 500; ++i) {
   classic[i] = 0;
   unfixed[i] = 0;
   fixed[i] = 0;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Classic
for (var ii = 0; ii < 500; ++ii) {
 classic[ii] += 1;
}
ready
Unfixed
for (var ii = 0; ii < 500; ++ii) {
 unfixed[ii] += 1;
}
ready
Fixed
for (var ii = 0; ii < 500; ++ii) {
 fixed[ii] += 1;
}
ready

Revisions

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