canvas-clear

JavaScript performance comparison

Revision 14 of this test case created by Ben Wong

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var c = document.createElement('canvas');
  c.width = 1920;
  c.height = 1080;
  
  var ctx = c.getContext('2d');
  ctx.fillStyle = '#000';
  ctx.fillRect(0, 0, 1920, 1080);
  
  var fill, global;
  

};

Benchmark.prototype.teardown = function() {
  var p = ctx.getImageData(0, 0, 1, 1);
  if (p.data[3] != 0) throw ("canvas did not clear!");

};
</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
ctx.clearRect(0, 0, c.width, c.height);
pending…
fillRect
global = ctx.globalCompositeOperation;
fill = ctx.fillStyle;
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = 'rgba(0,0,0,0)';
ctx.fillRect(0, 0, c.width, c.height);
ctx.globalCompositeOperation = global;
ctx.fillStyle = fill;
pending…
set width
c.width = c.width;
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