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
<script>
var items = [1,2,3,4,5,6,7];
var allowedItems = [1,2,3];
var allowedItemsSet = new Set(allowedItems);
var allowedItemsObject = allowedItems.reduce((acc, curr) => {
return {...acc, [curr]: true }
}, {});;
function getRandomItem() {
return items[Math.floor(Math.random()*items.length)];
}
function getItem() {
return getRandomItem();
}
function ifCheck(item) {
if (item === allowedItems[0] || item === allowedItems[1] || item === allowedItems[2] ) {
return true;
}
return false;
}
function objCheck(item) {
if (allowedItemsObject[item]) {
return true;
}
return false;
}
function includesCheck(item) {
if (allowedItems.includes(item)) {
return true;
}
return false;
}
function setCheck(item) {
if (allowedItemsSet.has(item)) {
return true;
}
return false;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
If statements |
| ready |
Hash |
| ready |
Array.includes |
| ready |
Set |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.