canvas-clear (v6)

Revision 6 of this benchmark created on


Description

Different methods for clearing the canvas.

Preparation HTML

<script>
  var c = document.createElement('canvas');
  c.width = c.height = 500;
  var ctx = c.getContext('2d');
  ctx.fillStyle = 'rgba(0,0,0,1)';

  var angle = Math.PI/4;


</script>

Test runner

Ready to run.

Testing in
TestOps/sec
非自己管理
   ctx.save();
   ctx.translate(100  , 0);
   ctx.rotate(angle);
   ctx.fillRect(0 , 0 , 20 , 20);
   ctx.restore();
ready
自己管理
   var fs = Math.sin(angle);
   var fc = Math.cos(angle);

   ctx.save();
   ctx.setTransform(fc , fs , -fs, fc ,100 , 0);
   ctx.fillRect(0 , 0 , 20 , 20);
   ctx.restore();
ready

Revisions

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