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
var getFromMap = (function(){
var map = {
foo: 1,
bar: 2,
doh: 3,
baz: -1
};
return function(n) {
return map[n] || 0;
};
})();
function getFromSwitch(n) {
switch(n) {
case 'foo': return 1;
case 'bar': return 2;
case 'doh': return 3;
case 'baz': return -1;
default: return 0;
}
};
function getFromIf(n) {
if (n == 'foo') return 1;
if (n == 'bar') return 2;
if (n == 'doh') return 3;
if (n == 'baz') return -1;
return 0;
};
var ret = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
map |
| ready |
switch |
| ready |
if |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.