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
checks performance of the many types of case iterators in javascript.
function Switch(x) {
switch (x) {
case 1:
return 10;
case 2:
return 18448;
case 3:
return 188888;
case 4:
return 166;
case 5:
return 1516;
case 6:
return 11105;
case 7:
return 1215;
default:
return 1116;
}
}
function elseIf(x) {
if (x === 1) return 10;
else if (x === 2) return 18448;
else if (x === 3) return 188888;
else if (x === 4) return 166;
else if (x === 5) return 1516;
else if (x === 6) return 11105;
else if (x === 7) return 1215;
else return 1116;
}
var testObject = {
1: 10,
2: 18448,
3: 188888,
4: 166,
5: 1516,
6: 11105,
7: 1215,
8: 1116
};
function objects(x) {
return testObject[x];
}
var testArray = [10, 18448, 188888, 166, 1516, 11105, 1215, 1116];
function arrays(x) {
return testArray[x - 1];
}
function ternary(x) {
return x == 1 ? 10 : x == 2 ? 18448 : x == 3 ? 188888 : x == 4 ? 166 : x == 5 ? 1516 : x == 6 ? 11105 : x == 7 ? 1215 : 1116;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
switch |
| ready |
if else |
| ready |
indexed arrays |
| ready |
object |
| ready |
ternary |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.