Comparing Onscreen & Offscreen Rendering to Canvas

JavaScript performance comparison

Test case created by M.

Info

Just a quick test to see if their is any performance penalty in drawing off-screen (partially or fully) to a canvas.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>
<script type="text/javascript">
    var cntx = null;
    window.addEvent('domready', function() {
        cntx = $('surface').getContext('2d');
    });
</script>

<canvas id="surface" width="500" height="350" style="border: 1px solid #CCC;"></canvas>
<script>
Benchmark.prototype.setup = function() {
    cntx.clearRect(0,0,500,350);
};
</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
Within Bounds
cntx.fillRect(40, 50, 30, 40);
pending…
Partially Within Bounds
cntx.fillRect(-10, -20, 30, 40);
pending…
Out of Bounds
cntx.fillRect(-60, -70, 30, 40);
pending…

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

Compare results of other browsers

1 comment

Add a comment