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
function andOrTest(stuff) {
return (stuff === "pizza" && "food") ||
(stuff === "house" && "building") ||
(stuff === "table" && "furniture") ||
(stuff === "car" && "driving") ||
(stuff === "water" && "drink") ||
(stuff === "air" && "nothing") || (true && undefined);
};
function inlineTest(stuff) {
return (stuff === "pizza") ? "food" :
(stuff === "house") ? "building" :
(stuff === "table") ? "furniture" :
(stuff === "car") ? "driving" :
(stuff === "water") ? "drink" :
(stuff === "air") ? "nothing" : '';
};
function ifElseTest(stuff) {
if (stuff === "pizza") {
return "food";
} else if (stuff === "house") {
return "building";
} else if (stuff === "table") {
return "furniture";
} else if (stuff === "car") {
return "driving";
} else if (stuff === "water") {
return "drink";
} else if (stuff === "air") {
return "nothing";
}
};
function switchTest(stuff) {
switch (stuff) {
case "pizza":
return "food";
break;
case "house":
return "building";
break;
case "table":
return "furniture";
break;
case "car":
return "driving";
break;
case "water":
return "drink";
break;
case "air":
return "nothing";
break;
}
};
function lookupTest(stuff) {
return {
"pizza": "food",
"house": "building",
"table": "furniture",
"car": "driving",
"water": "drink",
"air": "nothing"
}[stuff];
};
Ready to run.
Test | Ops/sec | |
---|---|---|
if else |
| ready |
switch |
| ready |
lookup table |
| ready |
andOrTest |
| ready |
inlineIfTest |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.