canvas-clear (v32)

Revision 32 of this benchmark created by bcd on


Description

Canvas size dependent test for clearing.

Setup

function createCanvas(size) {
       var c = document.createElement('canvas');
       c.width = c.height = size;
       document.body.appendChild(c);
       var ctx = c.getContext('2d');
       ctx.fillStyle = '#100';
       ctx.fillRect(0, 0, c.width, c.height);
       return c;
    }
    
    var c1 = createCanvas(256);
    var ctx1 = c1.getContext('2d');
    var c2 = createCanvas(512);
    var ctx2 = c2.getContext('2d');
    var c3 = createCanvas(1024);
    var ctx3 = c3.getContext('2d');
    var c4 = createCanvas(2048);
    var ctx4 = c4.getContext('2d');

Test runner

Ready to run.

Testing in
TestOps/sec
clearRect 256
ctx1.clearRect(0, 0, c1.width, c1.height);
 
ready
setWidth 256
c1.width = c1.width
ready
clearRect 512
ctx2.clearRect(0, 0, c2.width, c2.height);
ready
setWidth 512
c2.width = c2.width
ready
clearRect 1024
ctx3.clearRect(0, 0, c3.width, c3.height);
ready
setWidth 1024
c3.width = c3.width
ready
clearRect 2048
ctx4.clearRect(0, 0, c4.width, c4.height);
ready
setWidth 2048
c4.width = c4.width
ready

Revisions

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