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
states are restored in case that's a factor. 'draw normal' and 'draw normal with state' is just for comparison
source image:<br/>
<canvas id="sourceImg" width="64" height="64"></canvas>
<br/><br/>destination canvas:<br/>
<canvas id="drawHere" width="128" height="128"></canvas>
<script>
var sourceCanvas = document.getElementById('sourceImg');
var sourceCtx = sourceCanvas.getContext('2d');
sourceCtx.beginPath();
sourceCtx.arc(32,32,32,0,Math.PI);
sourceCtx.fill();
sourceCtx.beginPath();
sourceCtx.fillStyle = "red";
sourceCtx.arc(32,32,32,Math.PI,0);
sourceCtx.fill();
var drawCanvas = document.getElementById('drawHere');
var drawCtx = drawCanvas.getContext('2d');
function drawNormal(){
drawCtx.drawImage(sourceCanvas,0,0);
}
function drawNormalWithState(){
drawCtx.save();
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
function drawRotate(){
drawCtx.save();
drawCtx.rotate(Math.PI/4);
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
function drawScale(){
drawCtx.save();
drawCtx.scale(1.5,1.5);
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
function drawScaleAndRotate(){
drawCtx.save();
drawCtx.scale(1.5,1.5);
drawCtx.rotate(Math.PI/4);
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
function drawAlpha(){
drawCtx.save();
drawCtx.globalAlpha = 0.5;
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
function drawAlphaAndRotate(){
drawCtx.save();
drawCtx.globalAlpha = 0.5;
drawCtx.rotate(Math.PI/4);
drawCtx.drawImage(sourceCanvas,0,0);
drawCtx.restore();
}
</script>
drawCtx.clearRect(0,0,128,128);
Ready to run.
Test | Ops/sec | |
---|---|---|
draw normal |
| ready |
drawNormalWithState |
| ready |
draw rotated |
| ready |
draw scaled |
| ready |
draw rotated and scaled |
| ready |
draw transparent |
| ready |
draw transparent and rotated |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.