canvas clear

Benchmark created on


Preparation HTML

<canvas id="canvas" width="400" height="400"></canvas>
<script>
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  
  var width = canvas.width;
  var height = canvas.height;
  
  ctx.fillStyle = '#fff';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
clearRect with variable w/h
ctx.fillRect(20, 20, 100, 100);
ctx.clearRect(0, 0, width, height);
ready
width = width
ctx.fillRect(20, 20, 100, 100);
canvas.width = width;
ready
width = number
ctx.fillRect(20, 20, 100, 100);
canvas.width = 400;
ready
fillRect
ctx.fillRect(20, 20, 100, 100);
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.