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
<html>
<head>
</head>
<body>
<script>
var boxElement = document.createElement('div');
var imgElement = document.createElement('img');
var viewWidth = window.innerWidth;
var viewHeight = window.innerHeight;
var baseSize = 300;
var imgAssignArr = [];
var imgAssignFlagArr = [];
var showImgIndex = 0;
var init = function () {
boxElement.id = "box";
baseSize = Math.floor(viewWidth / 4);
if (viewWidth * 0.75 > viewHeight) {
baseSize = Math.floor(viewHeight / 3);
}
assignImg();
mobileHandle();
boxElement.style.width = baseSize * 4;
boxElement.style.height = baseSize * 3;
boxElement.style.backgroundColor = "#eee";
boxElement.style.margin = "auto";
document.body.appendChild(boxElement);
}
var assignImg = function () {
for(var i = 11; i >= 0 ; i--) {
var index = random();
imgAssignArr.push({
x: baseSize * (index % 4),
y: baseSize * Math.floor(index / 4)
})
}
setTimeout(addImg, 1000);
}
var random = function () {
var randomNum = Math.floor(Math.random() * 12);
while(imgAssignFlagArr[randomNum] !== undefined) {
randomNum = Math.floor(Math.random() * 12);
}
imgAssignFlagArr[randomNum] = true;
return randomNum;
}
var addImg = function () {
var newImg = imgElement.cloneNode();
newImg.width = baseSize;
newImg.height = baseSize;
newImg.style.position = "absolute";
newImg.src = "images/" + showImgIndex + ".png";
newImg.style.marginLeft = imgAssignArr[showImgIndex].x;
newImg.style.marginTop = imgAssignArr[showImgIndex].y;
boxElement.appendChild(newImg);
showImgIndex = showImgIndex + 1;
if (showImgIndex < 12) {
setTimeout(addImg, 1000);
}
}
var mobileHandle = function () {
console.log('modileHandler');
window.addEventListener("orientationchange", function() {
alert("the orientation of the device is now " + screen.orientation);
});
}
init();
</script>
</body>
</html>
Ready to run.
Test | Ops/sec | |
---|---|---|
test |
| ready |
test1 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.