render-vs-prerender

JavaScript performance comparison

Revision 139 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 context= document.createElement('canvas');
context.width = 1800;
context.height = 900;
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() {
    for(var i = 0; i< 3; i++){
        can.drawImage(can3, 0, 0);
    }
}

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

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

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

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

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

Preparation code output

<canvas id="canvas1" width="1800" height="900"></canvas> <script> var can = document.getElementById('canvas1'); var ctx = can.getContext('2d'); var context= document.createElement('canvas'); context.width = 1800; context.height = 900; 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() { for(var i = 0; i< 3; i++){ can.drawImage(can3, 0, 0); } } function render_snug() { for(var i = 0; i< 3; i++){ can.drawImage(can2, 0, 0); } } function pre_render(context) { for(var i = 0; i< 3; i++){ context.drawImage(can3, 0, 0); } can.drawImage(context, 0 , 0); } function pre_render_snug(context) { for(var i = 0; i< 12; i++){ context.drawImage(can2, 0, 0); } can.drawImage(context, 0 , 0); }

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