Typed array iteration (v6)

Revision 6 of this benchmark created by vjeux on


Description

Added Canvas

Preparation HTML

<canvas width="10" height="50" id="canvas"></canvas>
<script>
  var classic = new Array(2000);
  var canvas = document.getElementById("canvas").getContext("2d").getImageData(0, 0, 10, 50).data; // 50 * 10 * 4 = 2000
  var unfixed = new Uint8Array();
  var fixed = new Uint8Array(2000);
  for (var i = 0; i < 2000; ++i) {
   var number = ~~ (Math.random() * 200)
   classic[i] = number;
   canvas[i] = number;
   unfixed[i] = number;
   fixed[i] = number;
  }
</script>

Test runner

Ready to run.

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

Revisions

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