Canvas drawImage() draw canvas into itself

Benchmark created on


Preparation HTML

<script>
  var c = document.createElement('canvas');
  c.width = 256;
  c.height = 256;
  
  var ctx = c.getContext('2d');
  ctx.fillRect(64, 64, 128, 128);

  var img = new Image();
  img.src = c.toDataURL();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Copy, unscaled
ctx.drawImage(ctx.canvas, 0, 0);
ready
Copy, scaled
ctx.drawImage(ctx.canvas, 0, 0, ctx.canvas.width*2, ctx.canvas.height*2);
ready
Draw image
ctx.drawImage(img, 0, 0);
ready

Revisions

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