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>
var array = [
"The string is for case 'a'",
"The string is for case 'b'",
"The string is for case 'c'",
"The string is for case 'd'",
"The string is for case 'e'",
"The string is for case 'f'",
"The string is for case 'g'",
"The string is for case 'h'",
"The string is for case 'i'",
"The string is for case 'j'"];
var objDictionary = {
'a' : "The string is for case 'a'",
'b' : "The string is for case 'b'",
'c' : "The string is for case 'c'",
'd' : "The string is for case 'd'",
'e' : "The string is for case 'e'",
'f' : "The string is for case 'f'",
'g' : "The string is for case 'g'",
'h' : "The string is for case 'h'",
'i' : "The string is for case 'i'",
'j' : "The string is for case 'j'"
}
var objFuncDictionary = {
'a' : function() {return "The string is for case 'a'";},
'b' : function() {return "The string is for case 'b'";},
'c' : function() {return "The string is for case 'c'";},
'd' : function() {return "The string is for case 'd'";},
'e' : function() {return "The string is for case 'e'";},
'f' : function() {return "The string is for case 'f'";},
'g' : function() {return "The string is for case 'g'";},
'h' : function() {return "The string is for case 'h'";},
'i' : function() {return "The string is for case 'i'";},
'j' : function() {return "The string is for case 'j'";},
}
var arrayFns = [
function() {return "The string is for case 'a'";},
function() {return "The string is for case 'b'";},
function() {return "The string is for case 'c'";},
function() {return "The string is for case 'd'";},
function() {return "The string is for case 'e'";},
function() {return "The string is for case 'f'";},
function() {return "The string is for case 'g'";},
function() {return "The string is for case 'h'";},
function() {return "The string is for case 'i'";},
function() {return "The string is for case 'j'";},
]
function switchLookup(strKey) {
switch( strKey ) {
case 'a' :
return "The string is for case 'a'";
break;
case 'b' :
return "The string is for case 'b'";
break;
case 'c' :
return "The string is for case 'c'";
break;
case 'd' :
return "The string is for case 'd'";
break;
case 'e' :
return "The string is for case 'e'";
break;
case 'f' :
return "The string is for case 'f'";
break;
case 'g' :
return "The string is for case 'g'";
break;
case 'h' :
return "The string is for case 'h'";
break;
case 'i' :
return "The string is for case 'i'";
break;
case 'j' :
return "The string is for case 'j'";
break;
}
}
var rands = [], randc = [];
for(var i = 0; i < 100; i++) {
rands[i] = ~~(Math.random()*10);
randc[i] = String.fromCharCode(97 + rands[i]);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Lookup by object |
| ready |
Lookup by switch |
| ready |
Lookup by array |
| ready |
Lookup by object function |
| ready |
Lookup by array function |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.