32-bit hash-small

JavaScript performance comparison

Revision 3 of this test case created by Martin Wendt

Preparation code

<script src="https://rawgithub.com/garycourt/murmurhash-js/master/murmurhash3_gc.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  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";
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
murmur3
return murmurhash3_32_gc(this.text);
pending…
hashFnv32a
return hashFnv32a(this.text);
pending…
Java's toHash
return hashJavaDJB2(this.text);
pending…

Compare results of other browsers

Revisions

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

0 Comments