drawImage from different sources

JavaScript performance comparison

Revision 5 of this test case created by alekop

Info

Testing rendering performance when using drawImage with different sources (IMG vs offscreen CANVAS)

Preparation code

<canvas id="cnv" width="320" height="240">
</canvas>
<img id="img" src="http://mozilla.org/media/img/firefox/template/header-logo-inverse.png" style="display: none" />
<script>
Benchmark.prototype.setup = function() {
    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(320, 240);
   
    g_offscreenCanvas.getContext('2d').drawImage(g_img, 0, 0);
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
img
g_ctx.drawImage(g_img, 0, 0, 180, 70, 0, 0, 180, 70);
pending…
not-in-dom canvas
g_ctx.drawImage(g_offscreenCanvas, 0, 0, 180, 70, 0, 0, 180, 70);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment