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
Check if the key is a known string
const keys = ['bgb', 'bgf', 'bgq', 'bgr', 'bmb', 'bmf', 'bmq', 'bmr', 'bpb', 'bpf', 'bpq', 'bpr', 'bqb', 'bqf', 'bqq', 'bqr', 'mgb', 'mgf', 'mgq', 'mgr', 'mmb', 'mmf', 'mmq', 'mmr', 'mpb', 'mpf', 'mpq', 'mpr', 'mqb', 'mqf', 'mqq', 'mqr', 'sgb', 'sgf', 'sgq', 'sgr', 'smb', 'smf', 'smq', 'smr', 'spb', 'spf', 'spq', 'spr', 'sqb', 'sqf', 'sqq', 'sqr', 'vgb', 'vgf', 'vgq', 'vgr', 'vmb', 'vmf', 'vmq', 'vmr', 'vpb', 'vpf', 'vpq', 'vpr', 'vqb', 'vqf', 'vqq', 'vqr'];
function runWithSwitch(key) {
switch (key) {
case 'bgb':
case 'bgf':
case 'bgq':
case 'bgr':
case 'bmb':
case 'bmf':
case 'bmq':
case 'bmr':
case 'bpb':
case 'bpf':
case 'bpq':
case 'bpr':
case 'bqb':
case 'bqf':
case 'bqq':
case 'bqr':
case 'mgb':
case 'mgf':
case 'mgq':
case 'mgr':
case 'mmb':
case 'mmf':
case 'mmq':
case 'mmr':
case 'mpb':
case 'mpf':
case 'mpq':
case 'mpr':
case 'mqb':
case 'mqf':
case 'mqq':
case 'mqr':
case 'sgb':
case 'sgf':
case 'sgq':
case 'sgr':
case 'smb':
case 'smf':
case 'smq':
case 'smr':
case 'spb':
case 'spf':
case 'spq':
case 'spr':
case 'sqb':
case 'sqf':
case 'sqq':
case 'sqr':
case 'vgb':
case 'vgf':
case 'vgq':
case 'vgr':
case 'vmb':
case 'vmf':
case 'vmq':
case 'vmr':
case 'vpb':
case 'vpf':
case 'vpq':
case 'vpr':
case 'vqb':
case 'vqf':
case 'vqq':
case 'vqr': return true;
default: return false;
}
}
const DATA = {
"bgb": true,
"bgf": true,
"bgq": true,
"bgr": true,
"bmb": true,
"bmf": true,
"bmq": true,
"bmr": true,
"bpb": true,
"bpf": true,
"bpq": true,
"bpr": true,
"bqb": true,
"bqf": true,
"bqq": true,
"bqr": true,
"mgb": true,
"mgf": true,
"mgq": true,
"mgr": true,
"mmb": true,
"mmf": true,
"mmq": true,
"mmr": true,
"mpb": true,
"mpf": true,
"mpq": true,
"mpr": true,
"mqb": true,
"mqf": true,
"mqq": true,
"mqr": true,
"sgb": true,
"sgf": true,
"sgq": true,
"sgr": true,
"smb": true,
"smf": true,
"smq": true,
"smr": true,
"spb": true,
"spf": true,
"spq": true,
"spr": true,
"sqb": true,
"sqf": true,
"sqq": true,
"sqr": true,
"vgb": true,
"vgf": true,
"vgq": true,
"vgr": true,
"vmb": true,
"vmf": true,
"vmq": true,
"vmr": true,
"vpb": true,
"vpf": true,
"vpq": true,
"vpr": true,
"vqb": true,
"vqf": true,
"vqq": true,
"vqr": true
};
function runWithLookupValue(key) {
return Boolean(DATA[key]);
}
function runWithLookupIn(key) {
return key in DATA;
}
const seq = Array.from({length: 200}, () => Math.random() < 0.5 ? 'xxx' : keys[Math.floor(Math.random() * keys.length)]);
Ready to run.
Test | Ops/sec | |
---|---|---|
Switch |
| ready |
Lookup value |
| ready |
Lookup using "in" |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.