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
// Build a lot of average length string to test on
var strs=[];
var strbuff = 'a';
for (var i = 0; i < 1000; i++) {
var lc = strbuff.charAt(strbuff.length - 1);
if (lc == 9) {
strbuff += 'a';
} else if (lc == 'z') {
strbuff = strbuff.substr(0,strbuff.length -1);
strbuff += 'A';
} else if (lc == 'Z') {
strbuff = strbuff.substr(0,strbuff.length -1);
strbuff += '0';
} else {
strbuff = strbuff.substr(0,strbuff.length -1);
strbuff += String.fromCharCode(lc.charCodeAt(0)+1);
}
strs.push(strbuff);
}
function DJBHashv1(str) {
var hash = 5381;
for(var i = 0; i < str.length; i++) {
hash = 33 * hash + str.charCodeAt(i);
}
return hash;
}
function DJBHashv2(str) {
var hash = 5381;
for(var i = 0, l = str.length; i < l; i++) {
hash = 33 * hash + str.charCodeAt(i);
}
return hash;
}
function DJBHashv3(str) {
var hash = 5381;
for(var i = 0; i < str.length; i++) {
hash = ((hash << 5) + hash) + str.charCodeAt(i);
}
return hash;
}
function DJBHashv4(str) {
var hash = 5381;
for(var i = 0, l = str.length; i < l; i++) {
hash = ((hash << 5) + hash) + str.charCodeAt(i);
}
return hash;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
v1 |
| ready |
v2 |
| ready |
v3 |
| ready |
v4 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.