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
const f1 = () => {}
const f2 = () => {}
const f3 = () => {}
const f4 = () => {}
const f5 = () => {}
function getFnIf(level) {
if (level === "info") return f1;
else if (level === "warn") return f2;
else if (level === "error") return f3;
else if (level === "fatal") return f4;
else return f5;
}
function getFnSwitch(level) {
switch (level) {
case "warn":
return f1;
case "info":
return f2;
case "error":
return f3;
case "fatal":
return f4;
default:
return f5;
}
}
const lookup = {
'info': f1,
'warn': f2,
'error': f3,
'fatal': f4
}
function getFnLookupString(level) {
return lookup[level] || f5
}
const lookupN = {
'1': f1,
'2': f2,
'3': f3,
'4': f4
}
function getFnLookupN(level) {
return lookupN[level] || f5
}
const arr = [f1,f2,f3,f4,f5]
function getFnLookupA(level) {
return lookupN[level] || f5
}
Ready to run.
Test | Ops/sec | |
---|---|---|
if |
| ready |
switch |
| ready |
lookup with strings |
| ready |
lookup with number |
| ready |
lookup in array |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.