TSH vs java hash (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script>
function hashCodeImul(str) {
  var hash = 0,
    i, chr;
  if (str.length === 0) return hash;
  for (i = 0; i < str.length; i++) {
    chr = str.charCodeAt(i);
    hash = Math.imul(hash, 31) + chr;
    hash |= 0; // Convert to 32bit integer
  }
  return hash;
}

TSH=s=>{for(var i=0,h=9;i<s.length;)h=Math.imul(h^s.charCodeAt(i++),9**9);return h^h>>>9}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
java hash
hashCodeImul('h7jCVZctXxdjSEeEpEsbdJSJ3bYd5tw6')
ready
TSH
TSH('h7jCVZctXxdjSEeEpEsbdJSJ3bYd5tw6')
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.