drawImage from different sources (v53)

Revision 53 of this benchmark created by olydis on


Setup

function createCanvas(w, h) {
    var canvas = document.createElement('canvas');
    canvas.setAttribute('width', w);
    canvas.setAttribute('height', h);
    return canvas;
  }
  
  // globals
  var g_ctx = createCanvas(16, 16).getContext('2d');
  
  var g_img = new Image();
  g_img.src = '/favicon.ico'; //16x16
  
  var g_offscreenCanvas = createCanvas(16, 16);
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 0, 0);
  
  var g_offscreenCanvasImg = new Image();
  g_offscreenCanvasImg.src = g_offscreenCanvas.toDataURL();
  
  var x = Math.floor(Math.random() * 100);
  var y = Math.floor(Math.random() * 100);

Teardown



            x = Math.floor(Math.random() * 100);
  y = Math.floor(Math.random() * 100);
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
img
g_ctx.drawImage(g_img, x, y, 16, 16, 0, 0, 16, 16);
ready
not-in-dom canvas
g_ctx.drawImage(g_offscreenCanvas, x, y, 16, 16, 0, 0, 16, 16);
ready
img from canvas
g_ctx.drawImage(g_offscreenCanvasImg, x, y, 16, 16, 0, 0, 16, 16);
ready

Revisions

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