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