drawImage source comparison (v40)

Revision 40 of this benchmark created by Mehran Shakerinava on


Description

How does the source of drawImage affect performance?

Preparation HTML

<canvas id="drawCanvas"></canvas>
<canvas id="sourceCanvas" style="display:hidden"></canvas>
<script>
  var sourceCanvas = document.getElementById("sourceCanvas");
  var sourceCtx = sourceCanvas.getContext("2d");
  
  var drawCanvas = document.getElementById("drawCanvas");  
  var drawCtx = drawCanvas.getContext("2d");
  
  var image = document.createElement("img");
  image.src = "http://icons.iconarchive.com/icons/ph03nyx/super-mario/48/Retro-Mushroom-1UP-2-icon.png";

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
CanvasImageSource : HTMLImageElement
drawCtx.drawImage(image, 0, 0);
ready
CanvasImageSource : HTMLCanvasElement
drawCtx.drawImage(sourceCanvas, 0, 0);
ready
CanvasImageSource : CanvasRenderingContext2D
drawCtx.drawImage(sourceCtx, 0, 0);
ready

Revisions

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