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
Switch vs If-Else
function testSwitch(S, count) {
for (var j = 0; j < count; j++) {
switch (S.charAt(0)) {
case 'A':
break;
case 'C':
break;
case 'G':
break;
case 'T':
break;
}
}
}
function testIfElse(S, count) {
for (var j = 0; j < count; j++) {
if (S.charAt(0) === 'A') {
} else if (S.charAt(0) === 'C') {
} else if (S.charAt(0) === 'G') {
} else if (S.charAt(0) === 'T') {
}
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
testSwitch |
| ready |
testIfElse |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.