canvas-clearRect-size (v3)

Revision 3 of this benchmark created by Rob Boerman on


Description

Check if the canvas clearRect is (linearly) dependent on the size of the canvas

Preparation HTML

<script>
  var c = document.createElement('canvas');
  c.width = c.height = 500;
document.body.appendChild( c );
  var ctx = c.getContext('2d');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
clearRect 50
c.width = c.height = 100;

for (var i = 0; i < 100; i++) {
  ctx.clearRect(0, 0, c.width, c.height);
}
ready
clearRect 250
c.width = c.height = 250;

for (var i = 0; i < 100; i++) {
  ctx.clearRect(0, 0, c.width, c.height);
}
ready
clearRect 500
c.width = c.height = 500;

for (var i = 0; i < 100; i++) {
  ctx.clearRect(0, 0, c.width, c.height);
}
ready
clearRect 1000
c.width = c.height = 1000;

for (var i = 0; i < 100; i++) {
  ctx.clearRect(0, 0, c.width, c.height);
}
ready

Revisions

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