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 function1(x) {
switch (x) {
case 1:
return 111;
break;
case 2:
return 222;
break;
default:
return -1;
}
}
function function2(x) {
if (x == 1) return 111;
if (x == 2) return 222;
return -1;
}
function function3(x) {
let out = -1;
switch (x) {
case 1:
out = 111;
break;
case 2:
out = 222;
break;
}
return out;
}
function function4(x) {
let out = -1;
if (x == 1) {
out = 111;
} else if (x == 2) {
out = 222;
}
return out;
}
var tests = [...Array(100)].map((e,i) => i % 3)
Ready to run.
Test | Ops/sec | |
---|---|---|
switch-return |
| ready |
if-return |
| ready |
switch-var |
| ready |
if-var |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.