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 CASE1 () { console.log('1') }
function CASE2 () { console.log('2') }
function CASE3 () { console.log('3') }
function CASE4 () { console.log('4') }
function CASE5 () { console.log('5') }
function CASE6 () { console.log('6') }
function defaulter () { console.log('default') }
const arrayed = [
() => { console.log('1') },
() => { console.log('2') },
() => { console.log('3') },
() => { console.log('4') },
() => { console.log('5') },
() => { console.log('6') },
]
function switcher(selector) {
switch (selector) {
case 'CASE1': return CASE1();
case 0: return console.log('0')
case 'CASE2': return CASE2();
case 'CASE3': return CASE3();
case 'CASE4': return CASE4();
case 'CASE5': return CASE5();
case 6: return console.log('6')
case 'CASE6': return CASE6();
default: defaulter()
}
}
const objection = {
'CASE1' () { CASE1(); },
'CASE2' () { CASE2(); },
'CASE3' () { CASE3(); },
'CASE4' () { CASE4(); },
'CASE5' () { CASE5(); },
'CASE6' () { CASE6(); },
}
function objecter(selector) {
const operator = objection[selector]
if (operator) {
operator()
} else {
defaulter()
}
}
function ifer(selector) {
if (selector === 'CASE1') { return CASE1() }
else if (selector === 'CASE2') { return CASE2() }
else if (selector === 'CASE3') { return CASE3() }
else if (selector === 'CASE4') { return CASE4() }
else if (selector === 'CASE5') { return CASE5() }
else if (selector === 'CASE6') { return CASE6() }
else if (selector === 'CASE2') { return CASE2() }
else { defaulter() }
}
function arrayer(selector) {
arrayed[selector] ? arrayed[selector](selector) : defaulter()
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Switch 1rst result |
| ready |
Switch last result |
| ready |
Switch default result |
| ready |
Object 1rst result |
| ready |
Object last result |
| ready |
Object default result |
| ready |
If 1rst |
| ready |
If last |
| ready |
If default |
| ready |
Array 0 |
| ready |
Array 6 |
| ready |
Array null |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.