drawImage from different sources (v18)

Revision 18 of this benchmark created on


Preparation HTML

<canvas id="cnv" width="512" height="512">
</canvas>
<img id="img" src="http://mozilla.org/media/img/firefox/template/header-logo-inverse.png" style="display: none" />

Setup

function createCanvas(w, h) {
    var canvas = document.createElement('canvas');
    canvas.setAttribute('width', w);
    canvas.setAttribute('height', h);
    return canvas;
  }
  
  // globals
  var g_ctx = document.getElementById('cnv').getContext('2d');
  var g_img = document.getElementById('img');
  var g_offscreenCanvas = createCanvas(1024,1024);
  var g_offscreenCanvas2 = createCanvas(1024,1024);
  var can2=g_offscreenCanvas2.getContext('2d');
  
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 0, 0);
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 100, 100);
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 200, 200);
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 300, 300);
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 400, 400);

Test runner

Ready to run.

Testing in
TestOps/sec
img
g_ctx.drawImage(g_img, 0, 0, 180, 70, 0, 0, 180, 70);
ready
not-in-dom canvas
g_ctx.drawImage(g_offscreenCanvas, 0, 0, 180, 70, 0, 0, 180, 70);
ready
not-in-dom canvas without sizes
g_ctx.drawImage(g_offscreenCanvas, 0, 0);
ready
img w/o sizes
g_ctx.drawImage(g_img, 0, 0);
ready
test2
g_ctx.drawImage(g_offscreenCanvas, 20, 20, 180, 70, 10, 10, 180, 70);
ready
off-2-off
can2.drawImage(g_offscreenCanvas, 20, 20, 180, 70, 10, 10, 180, 70);
ready

Revisions

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