canvas-clear

JavaScript performance comparison

Revision 32 of this test case created by bcd

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  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');

};
</script>

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
clearRect 256
ctx1.clearRect(0, 0, c1.width, c1.height);
pending…
setWidth 256
c1.width = c1.width
pending…
clearRect 512
ctx2.clearRect(0, 0, c2.width, c2.height);
pending…
setWidth 512
c2.width = c2.width
pending…
setWidth 2048
c4.width = c4.width
pending…
clearRect 1024
ctx3.clearRect(0, 0, c3.width, c3.height);
pending…
setWidth 1024
c3.width = c3.width
pending…
clearRect 2048
ctx4.clearRect(0, 0, c4.width, c4.height);
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