drawImage from different sources (v20)

Revision 20 of this benchmark created on


Preparation HTML

<canvas id="cnv0" width="250" height="250"></canvas>
<canvas id="cnv1" width="320" height="240"></canvas>
<canvas id="cnv2" width="512" height="512"></canvas>
<img id="img" src="http://mozilla.org/media/img/firefox/template/header-logo-inverse.png" />

Setup

function createCanvas(w, h) {
    var canvas = document.createElement('canvas');
    canvas.setAttribute('width', w);
    canvas.setAttribute('height', h);
    return canvas;
  }
  
  
  // globals
  var g_ctx0 = createCanvas(250, 250).getContext('2d');
  var g_ctx1 = createCanvas(512, 512).getContext('2d');
  var g_ctx2 = createCanvas(1024, 1024).getContext('2d');
  g_ctx2.globalCompositeOperation = "copy";
  var g_img = document.getElementById('img');
  var g_offscreenCanvas = createCanvas(512, 512);
  
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 0, 0);

Test runner

Ready to run.

Testing in
TestOps/sec
img normal
g_ctx1.drawImage(g_img,0,0);
ready
not-in-dom canvas normal
g_ctx1.drawImage(g_offscreenCanvas,0,0);
ready
img copy
g_ctx2.drawImage(g_img,0,0);
ready
offsceen copy
g_ctx2.drawImage(g_offscreenCanvas,0,0);
ready
little img
g_ctx0.drawImage(g_img,0,0);
ready
little can
g_ctx0.drawImage(g_offscreenCanvas,0,0);
ready

Revisions

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