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>
/* Lightweight universal hashing function
** Copyright (c) Jonas Fischer, freewos.com 2011
** @webseite: http://freewos.com/
** @author: Jonas Fischer
** @version: 0.9
** @stable: yes
** @url: http://freewos.com/system/tech/luh/main.php
** @first argument String (for generating hash code)
** Creates and returns a hash unsignet Integer (<= 2^32) from any String.
** Saves althought the length of the String.
** If the length is bigger than 2^15 the length will be length % 2^15.
** Security:
** It normally may exapt although another String,
** because it is for checking for example a password with JavaScript.
** It´s build for clientside validation additonal to the serverside hashing funktions.
** I have checked it with a own build hacking funtion and
** I could not really got so mutch posibile matches,
** that I can can really say - Its not really a help for a hacker to find the password.
** So you can use It via JavaScript without worry about the security!
** In this case its perfect - For this case it althought had been built!
** */
function luh(v) {
var h = 32768,
l = v.length;
for (var i = 0, s = l < 7 ? l >> 1 : l < 32 ? l >> 2 : l >> 3; i < l; i++) {
h += 128 - v.charCodeAt(i) >> (h > 49152 ? 2 : 1) << i % s;
if (h < 24576) h += h < 128 ? 512 : 12;
else if (h > 49152) h = h > 65536 ? h - 24 : h >> 1;
}
h = (h << 15) + ((l << 17) >> 17);
return h;
}
function luh_len(h) {
return (h << 17) >> 17;
}
function luh_improve(v) {
var h = 32768,
l = v.length;
for (var i = 0, s = l < 7 ? l >> 1 : l < 32 ? l >> 2 : l >> 3; i < l; i++) {
h += (127 & ~v.charCodeAt(i)) >> (h > 49152 ? 2 : 1) << i % s;
if (h < 24576) h += h < 128 ? 512 : 12;
else if (h > 49152) h = h > 65536 ? h - 24 : h >> 1;
}
h = (h << 15) + ((l << 17) >> 17);
return h;
}
var h = "fsdkkkgjlsdfgjdf";
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
luh |
| ready |
luh_improve |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.