canvas-vs-image

JavaScript performance comparison

Test case created by Simon

Info

Don't run until you see at least one kitten!

Preparation code

<canvas id="canvas1" width="100" height="100"></canvas>
<canvas id="canvas2" width="100" height="100"></canvas>

<script>

var can = document.getElementById('canvas1');
var ctx = can.getContext('2d');

var can2 = document.getElementById('canvas2');
var ctx2 = can2.getContext('2d');

var img = new Image();
img.src = 'http://placekitten.com/100/100';
img.onload = function() {
  ctx2.drawImage(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
draw image
ctx.drawImage(img, 0, 0);
pending…
draw canvas
ctx.drawImage(can2, 0, 0);
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