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
Checking draw speed of the drawImage canvas method of an Image loaded from URL, an Image from dataURL and another canvas.
Based on http://jsperf.com/fastest-canvas-drawing but that one was throwing errors for me.
<canvas width=500 height=500></canvas>
<script>
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
var url = 'http://jsperf.com/apple-touch-icon.png';
var dataImage = new Image();
var canvasImage = document.createElement('canvas');
var imageWidth = 120;
var imageHeight = 120;
var img = new Image();
img.onload = function() {
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = imageWidth;
tmpCanvas.height = imageHeight;
var c = tmpCanvas.getContext('2d');
c.drawImage(img, 0, 0);
dataImage.src = tmpCanvas.toDataURL();
var canvasImageContext = canvasImage.getContext('2d');
canvasImageContext.width = imageWidth;
canvasImageContext.height = imageHeight;
canvasImageContext.drawImage(img, 0, 0);
}
img.src = url;
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Web URL Image |
| ready |
Canvas Image |
| ready |
Image dataURL |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.