canvas-clear
JavaScript performance comparison
Info
Different methods for clearing the canvas.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var c = document.createElement('canvas');
c.width = 1920;
c.height = 1080;
var ctx = c.getContext('2d');
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 1920, 1080);
var fill, global;
};
Benchmark.prototype.teardown = function() {
var p = ctx.getImageData(0, 0, 1, 1);
if (p.data[3] != 0) throw ("canvas did not clear!");
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
clearRect |
|
pending… |
fillRect |
|
pending… |
set width |
|
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:
- Revision 1: published by Ilmari Heikkinen
- Revision 3: published by Rob Boerman
- Revision 5: published by Kashey
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published by Prestaul
- Revision 10: published
- Revision 11: published by Matthew
- Revision 12: published by Leo Dutra
- Revision 14: published by Ben Wong
- Revision 15: published
- Revision 16: published and last updated
- Revision 17: published
- Revision 18: published by Jarrod Oberto
- Revision 19: published by Jarrod Oberto
- Revision 20: published
- Revision 21: published
0 comments