canvas-clear (v39)

Revision 39 of this benchmark created on


Description

Different methods for clearing a black canvas.

Preparation HTML

<canvas id="c" width="640" height="480"></canvas>
<script>
  var canvas = document.getElementById('c');
  var ctx = canvas.getContext('2d');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
clearRect + fillRect + draw
for (var i = 0; i < 100; i++) {
  ctx.clearRect(0, 0, 640, 480);
  ctx.fillStyle = 'black';
  ctx.fillRect(0, 0, 640, 480);
  ctx.fillStyle = 'rgb(255, 255, 255)';
  ctx.fillRect(320, 240, 1, 1);
}
ready
fillRect + draw
for (var i = 0; i < 100; i++) {
  ctx.fillStyle = 'black';
  ctx.fillRect(0, 0, 640, 480);
  ctx.fillStyle = 'rgb(255, 255, 255)';
  ctx.fillRect(320, 240, 1, 1);
}
ready

Revisions

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