Canvas Draw Image vs fill rect

JavaScript performance comparison

Revision 11 of this test case created

Preparation code

<canvas id="myCanvas" width="600" height="400"></canvas>
<img id="myImg" src="" />
Benchmark.prototype.setup = function() {
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');
    var m_canvas = document.createElement('canvas');
            m_canvas.width = 8;
            m_canvas.height = 8;                                
            var m_context = m_canvas.getContext('2d');
            m_context.fillStyle = '#ccc';
            m_context.fillRect(0, 0, m_canvas.width, m_canvas.height);

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(m_canvas, 0, 0, 8, 8);
Fill Rect
ctx.fillStyle = '#ccc';
ctx.fillRect(0, 0, 8, 8);

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment