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
Testing 'reasonable' methods to set one pixel on an HTML5 Canvas; used to support this Stack Overflow question.
<p>(Scroll down to see the 'Run Tests' button.)</p>
<canvas id="c" width="480" height="480"></canvas>
<script>
$c = document.getElementById('c');
$ctx = $c.getContext('2d');
$ctx.clearRect(0, 0, 480, 480);
$buf = $ctx.getImageData(0, 0, 480, 480);
$scale = 4;
$px = [
$ctx.createImageData($scale, $scale),
$ctx.createImageData($scale, $scale),
$ctx.createImageData($scale, $scale),
$ctx.createImageData($scale, $scale)
];
for (var i = 0, ilen = $px.length; i < ilen; i++) {
var d = $px[i].data;
for (var j = 0, jlen = d.length; j < jlen; j+=4) {
d[j+0] = 64 * i + 63;
d[j+1] = 64 * i + 63;
d[j+2] = 64 * i + 63;
d[j+3] = 255;
}
}
$fs = [
'rgba('+(64*0+63)+','+(64*0+63)+','+(64*0+63)+',255)',
'rgba('+(64*1+63)+','+(64*1+63)+','+(64*1+63)+',255)',
'rgba('+(64*2+63)+','+(64*2+63)+','+(64*2+63)+',255)',
'rgba('+(64*3+63)+','+(64*3+63)+','+(64*3+63)+',255)'
];
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
blit image data |
| ready |
fillRect |
| ready |
put image data |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.