render-vs-prerender

JavaScript performance comparison

Revision 144 of this test case created by

Preparation code

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

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

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

        pre_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(ctx) {
            for (var i = 0; i < 3; i++) {
                context.drawImage(can3, 0, 0);
            }
        }

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

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

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

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

            context.drawImage(pre_canvas, 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
pre-rendered loose
pre_render_snug();
pending…
render
render();
pending…
pre-rendered snug
pre_render();
pending…
render snug
render_snug();
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