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="160" height="144"></canvas>
<style type="text/css">
canvas {
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;
border: 5px solid #ddd;
width: 640px;
height: 574px;
}
</style>
<script>
$c = document.getElementById('c');
$ctx = $c.getContext('2d');
$ctx.imageSmoothingEnabled = false;
$ctx.webkitImageSmoothingEnabled = false;
$ctx.mozImageSmoothingEnabled = false;
$ctx.clearRect(0, 0, $c.width, $c.height);
$buf = $ctx.getImageData(0, 0, $c.width, $c.height);
$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.