jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Test various canvas clearing methods
<canvas id="test"></canvas>const canvas = document.getElementById('test');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(20, 40, 120, 300);
ctx.rotate(30);
ctx.fillStyle = 'blue';
ctx.fillRect(-10, -40, 200, 100);
ctx.translate(40, 60);
ctx.fillStyle = 'green';
ctx.fillRect(100, 180, 50, 80);
ctx.fillStyle = 'yellow';
ctx.fillRect(180, 90, 120, 100);
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| clearRect with setTransform | | ready |
| clearRect with setTransform and save/restore | | ready |
| clearRect with resetTransform | | ready |
| clearRect with resetTransform and save/restore | | ready |
| canvas.width = canvas.width | | ready |
| canvas.width += 0 | | ready |
| ctx.reset | | ready |
| with a flag (true) | | ready |
| with a flag (false) | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.