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
<canvas id="canvas" />const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 100;
canvas.height = 100;
const points = [];
for (let x = 0; x < 100; x++) {
for (let y = 0; y < 100; y++) {
points.push({x, y})
}
}
const tenPoints = points.slice(0, 10);
// for prerendering
const offscreenCanvas = new OffscreenCanvas(100, 100);
const offctx = offscreenCanvas.getContext('2d');
offctx.beginPath();
for (let i = 0; i < points.length - 1; i++) {
const p1 = points[i];
const p2 = points[i+1];
offctx.moveTo(p1.x, p1.y);
offctx.lineTo(p2.x, p2.y);
}
offctx.stroke();
const prerenderedImage = offscreenCanvas.transferToImageBitmap();
const offscreenCanvas2 = new OffscreenCanvas(1, 1);
const offctx2 = offscreenCanvas2.getContext('2d');
offctx2.beginPath();
offctx2.moveTo(0, 0);
offctx2.lineTo(1, 0);
offctx2.stroke();
const prerenderedSegment = offscreenCanvas2.transferToImageBitmap();
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Segmented line draws | | ready |
| Single line draw | | ready |
| Smaller amount of lines (segmented draw) | | ready |
| Smaller amount of lines (single draw) | | ready |
| Prerendered full image draw | | ready |
| Prerendered segmented draws | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.