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
<script>
function getType1(type) {
switch (type) {
case 'type0':
type = 'Type0';
break;
case 'type1':
type = 'Type1';
break;
case 'type2':
type = 'Type2';
break;
case 'type3':
type = 'Type3';
break;
case 'type4':
type = 'Type4';
break;
case 'type5':
type = 'Type5';
break;
case 'type6':
type = 'Type6';
break;
case 'type7':
type = 'Type7';
break;
case 'type8':
type = 'Type8';
break;
case 'type9':
type = 'Type9';
break;
case 'type10':
type = 'Type10';
break;
case 'type11':
type = 'Type11';
break;
case 'type12':
type = 'Type12';
break;
case 'type13':
type = 'Type13';
break;
case 'type14':
type = 'Type14';
break;
case 'type15':
type = 'Type15';
break;
case 'type16':
type = 'Type16';
break;
case 'type17':
type = 'Type17';
break;
case 'type18':
type = 'Type18';
break;
case 'type19':
type = 'Type19';
break;
}
return type;
}
function getType2(type) {
if (type === 'type0') {
type = 'Type0';
} else if (type === 'type0') {
type = 'Type0';
} else if (type === 'type1') {
type = 'Type1';
} else if (type === 'type2') {
type = 'Type2';
} else if (type === 'type3') {
type = 'Type3';
} else if (type === 'type4') {
type = 'Type4';
} else if (type === 'type5') {
type = 'Type5';
} else if (type === 'type6') {
type = 'Type6';
} else if (type === 'type7') {
type = 'Type7';
} else if (type === 'type8') {
type = 'Type8';
} else if (type === 'type9') {
type = 'Type9';
} else if (type === 'type10') {
type = 'Type10';
} else if (type === 'type11') {
type = 'Type11';
} else if (type === 'type12') {
type = 'Type12';
} else if (type === 'type13') {
type = 'Type13';
} else if (type === 'type14') {
type = 'Type14';
} else if (type === 'type15') {
type = 'Type15';
} else if (type === 'type16') {
type = 'Type16';
} else if (type === 'type17') {
type = 'Type17';
} else if (type === 'type18') {
type = 'Type18';
} else if (type === 'type19') {
type = 'Type19';
}
return type;
}
var drinks = {
'type0': 'Type0',
'type1': 'Type1',
'type2': 'Type2',
'type3': 'Type3',
'type4': 'Type4',
'type5': 'Type5',
'type6': 'Type6',
'type7': 'Type7',
'type8': 'Type8',
'type9': 'Type9',
'type10': 'Type10',
'type11': 'Type11',
'type12': 'Type12',
'type13': 'Type13',
'type14': 'Type14',
'type15': 'Type15',
'type16': 'Type16',
'type17': 'Type17',
'type18': 'Type18',
'type19': 'Type19'
};
var getType6 = (function() {
var drinks = {
'type0': 'Type0',
'type1': 'Type1',
'type2': 'Type2',
'type3': 'Type3',
'type4': 'Type4',
'type5': 'Type5',
'type6': 'Type6',
'type7': 'Type7',
'type8': 'Type8',
'type9': 'Type9',
'type10': 'Type10',
'type11': 'Type11',
'type12': 'Type12',
'type13': 'Type13',
'type14': 'Type14',
'type15': 'Type15',
'type16': 'Type16',
'type17': 'Type17',
'type18': 'Type18',
'type19': 'Type19'
};
return function(type) { return drinks[type] }
}());
function getType5(type) {
return drinks[type];
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
switch |
| ready |
if else |
| ready |
cached object literal |
| ready |
cached object literal 2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.