render-vs-prerender

JavaScript performance comparison

Revision 142 of this test case created by

Preparation code

    <canvas id="canvas1" width="1800" height="900"></canvas>

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

        var canvas = document.createElement('canvas');
        canvas.width = 1800;
        canvas.height = 900;

        var context = canvas.getContext('2d');

        var can2 = document.createElement('canvas');
        can2.width = 256;
        can2.height = 256;

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

        var can3 = document.createElement('canvas');
        can3.width = 512;
        can3.height = 512;
        var ctx3 = can3.getContext('2d');

        function render(can) {
            for (var i = 0; i < 3; i++) {
                can.drawImage(can3, 0, 0);
            }
        }

        function render_snug(can) {
            for (var i = 0; i < 3; i++) {
                can.drawImage(can2, 0, 0);
            }
        }

        function pre_render(context, can) {
            for (var i = 0; i < 3; i++) {
                context.drawImage(can3, 0, 0);
            }

            can.drawImage(context, 0, 0);
        }

        function pre_render_snug(context, can) {
            for (var i = 0; i < 12; i++) {
                context.drawImage(can2, 0, 0);
            }

            can.drawImage(context, 0, 0);
        }
    </script>
    

Preparation code output

<canvas id="canvas1" width="1800" height="900"></canvas>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
render
render(can);
pending…
pre-rendered loose
pre_render_snug(context, can);
pending…
pre-rendered snug
pre_render(context, can);
pending…
render snug
render_snug(can);
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.

0 Comments