canvas-clearRect-size

JavaScript performance comparison

Revision 3 of this test case created by Rob Boerman

Info

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

Preparation code

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
clearRect 50
c.width = c.height = 100;

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

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

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

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

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment