Draw Image Stretch VS No Stretch

Benchmark created by Austin on


Preparation HTML

<canvas id="src" width="100" height="100">
</canvas>
<canvas id="dst" width="100" height="100">
</canvas>
<script>
  var src = document.getElementById('src');
  var dst = document.getElementById('dst');
  var src_ctx = src.getContext('2d');
  var dst_ctx = dst.getContext('2d');

  var imageData = src_ctx.createImageData(100, 100);
  var data = imageData.data;
  var i = 0;
  while (i < 100 * 100 * 4) {
    data[i++] = Math.random() * 255 | 0;
    data[i++] = Math.random() * 255 | 0;
    data[i++] = Math.random() * 255 | 0;
    data[i++] = 255;
  }
  src_ctx.putImageData(imageData, 0, 0);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
No Stretch No Lengths
dst_ctx.drawImage(src, 0, 0);
ready
No Stretch
dst_ctx.drawImage(src, 0, 0, 100, 100);
ready
Stretch
//dst_ctx.drawImage(src, 0, 0 100, 100, 0, 0, 100, 100);
//dst_ctx.drawImage(src, 0, 0 100, 100);
ready

Revisions

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