canvasclear (v21)

Revision 21 of this benchmark created by Tymoteusz Beczek on


Preparation HTML

<canvas id="canvas1" width="500" height="500"></canvas>
<script>
  var can = document.getElementById('canvas1');
  var ctx = can.getContext('2d');
  var width = can.width;
  var height = can.height;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
setting width
can.width = can.width;
ready
clearing non-transformed canvas
ctx.clearRect(0, 0, width, height);
ready
clearing transformed canvas
// I have lots of transforms right now
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
// Will always clear the right space
ctx.clearRect(0, 0, width, height);
ctx.restore();
// Still have my old transforms
ready
fill
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, width, height);
ready

Revisions

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