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
Compare 32-bit hashing algorithms
See http://stackoverflow.com/q/7616461/19166
<script src="https://rawgithub.com/garycourt/murmurhash-js/master/murmurhash3_gc.js"></script>
function hashJavaDJB2(str) {
var hash = 0, i, char;
if (str == 0) return hash;
for (i = 0, l = str.length; i < l; i++) {
char = str.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
function hashFnv32a(str) {
/*jshint bitwise:false */
var i, l,
hval = 0x811c9dc5;
for (i = 0, l = str.length; i < l; i++) {
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
return hval >>> 0;
}
this.text = "foobar";
Ready to run.
Test | Ops/sec | |
---|---|---|
murmur3 |
| ready |
hashFnv32a |
| ready |
Java's toHash |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.