Canvas Draw Image vs fill rect

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

<canvas id="myCanvas" width="600" height="400"></canvas>
<img id="myImg" src="http://upload.wikimedia.org/wikipedia/commons/f/f0/Pixelart-tv-iso.png" />
<script>
Benchmark.prototype.setup = function() {
    canvas = document.getElementById('myCanvas');
    ctx = canvas.getContext('2d');
    img = document.getElementById('myImg');
   
};
</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
console.log(img.src);
ctx.drawImage(img, 0, 0, img.width, img.heigh);
pending…
Fill Rect
ctx.fillStyle='#FF0000';
ctx.fillRect(0, 0, img.width, img.height);
 
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