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 arr1 = ['alpha', 'beta', 'gama', 'delta', 'theta'];
var arr2 = arr1.reverse();
var theMap = {};
var lookup = function(arr, hashFn) {
var item = null;
var hashed = hashFn(arr);
if (item = theMap[hashed]) {
return item;
}
var item = {
arr: arr
};
theMap[hashed] = item;
return item;
};
function hashWithJoin(array) {
return array.sort().join('\u200b');
};
function hashWithXor(array) {
var code = 0;
for (var i = 0; i < array.length; i++) {
var n = 0;
for (var j = 0; j < array[i].length; j++) {
n = n * 251 ^ array[i].charCodeAt(j);
}
code ^= n;
}
return code
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Joining strings |
| ready |
Real hashing |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.