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
<style>
canvas { background: transparent; }
img { background-color: rgba(255, 0, 0, 0.5); }
</style>
<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAADACAMAAADcFhp9AAADAFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAQABBQACBwADCAAECQADCwAADAAAEAAFEQAAEQAGEwAHFgABFgAIGwACHAANHQAKIAAKIAANIgENIgEPIwANIwENIwEMJAEMJwAGKgAOKwAILgAHMAAHMgAHMwAKNAANNgAZNwARPQAUPgAWPwEmQABVQgB2RAAZSQAkUgAiVAAoWgAnWgAqXAArXgArYQEsYgEsYwEuZAEyZQIwZQExZAIvZgEuZgEvZgExZgEzZwIwaAEx6CQx6CQx5yMv4SEu3yAr1h0q1Rwo0BonyxkmyRkkwhgjvhgjuxghtxchtxcgshQfsBIfrhEerhEerhEerREdqxAcqQ8bog4aoQ4anAwZmwsYlgoYlAoYkwoYkAsYjQwYjQwYjQwXiQwWhg0VhQ0QggYQggYQgQYQggYVgA0Ufw0PfQQQfAYTew4Teg4Teg0PeQISeAoReAcRdwgRdwcRdwcPdwIPdAEPdAEObwINZwcNZgcLZgcLZgcMZgcNZgcKZAcIYQAIYQAIYQAIYQAIYQAJYAAJXgcLXQAHXgAHXAAMWwAMWwAMWwAMWwAHWgAHWgAHWgAHWgAHWgANWgARVwAHVAcHUwcfUAAHTgAHTgAHTQAHTQAHTQAHTQAsTQA+SwAHSgcHSgcHSgJgRwAHRgcHRgd+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WPwkQIZ0O6OWf3/+515WPn/Y5dAKgFy++EaSzk5Nnt5L5YuvzPwd79vrN/z0V0ddT6XFAfz7lh75J5nKVz/s9i0YunwzoxZ+nAfrjST/0TS6Tr+wB/RN98pYhRL8C0ItK5jBE1yfgORXQn0/7qUmE6Pri+h8m0nXyFDynbtnLp4XoIp/JXePDG67/OwXPqUn9pLJn5WfySXz468WJ6+SyfwoxysqvJF+cvH6EGL8vHTJCzeRfp8N5+UvENTBEJ8N5+Svtx4u/3pwWm5+1H98zaKeAeSaD9m0L+3Qsz2phv27yv4/kl5n8x9sgsY4Q/Hwb9P+UZOuulDUNOgAAAABJRU5ErkJggg=='/>
<canvas></canvas>
<canvas></canvas>
<script>
var _canvas = document.createElement("canvas");
var _ctx = _canvas.getContext("2d");
var getImageData = function (image) {
_canvas.width = image.width;
_canvas.height = image.height;
_ctx.drawImage(image, 0, 0);
return _ctx.getImageData(0, 0, image.width, image.height);
};
var drawImage = function (dstData, srcData) {
var src = srcData.data;
var dst = dstData.data;
var srcDataHeight = srcData.height;
var srcDataWidth = srcData.width;
var dstDataHeight = dstData.width;
var srcA, dstA, resultA, nSrcA;
var srcR, srcG, srcB, dstR, dstG, dstB;
var srcIndex, dstIndex;
for (var i = 0; i < srcDataHeight; i += 1) {
for (var j = 0; j < srcDataWidth; j += 1) {
srcIndex = (i * srcDataWidth + j) * 4;
dstIndex = (i * dstDataHeight + j) * 4;
srcA = src[srcIndex + 3] / 255;
dstA = dst[dstIndex + 3] / 255;
srcR = src[srcIndex ] * srcA;
dstR = dst[dstIndex ] * dstA;
srcG = src[srcIndex + 1] * srcA;
dstG = dst[dstIndex + 1] * dstA;
srcB = src[srcIndex + 2] * srcA;
dstB = dst[dstIndex + 2] * dstA;
nSrcA = 1 - srcA
resultA = srcA + dstA * nSrcA;
dst[dstIndex ] = (srcR + dstR * nSrcA) / resultA;
dst[dstIndex + 1] = (srcG + dstG * nSrcA) / resultA;
dst[dstIndex + 2] = (srcB + dstB * nSrcA) / resultA;
dst[dstIndex + 3] = resultA * 255;
}
}
return dstData;
};
var image = document.querySelector("img");
var srcData = getImageData(image);
var canvas1 = document.querySelectorAll("canvas")[0];
var canvas2 = document.querySelectorAll("canvas")[1];
var ctx1 = canvas1.getContext("2d");
var ctx2 = canvas2.getContext("2d");
canvas1.height = canvas2.height = image.height;
canvas1.width = canvas2.width = image.width;
ctx1.fillStyle = "rgba(255, 0, 0, 0.5)";
ctx2.fillStyle = "rgba(255, 0, 0, 0.5)";
ctx1.fillRect(0, 0, canvas1.width, canvas1.height);
ctx2.fillRect(0, 0, canvas2.width, canvas2.height);
var i, start;
var dstData = ctx1.getImageData(0, 0, canvas1.width, canvas1.height);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
ImageData manipulation (with blending) |
| ready |
ctx.drawImage() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.