Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Hashing algo
(version: 0)
Comparing performance of:
MurmurHash1 vs Cyrb53 vs SuperFastHash
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = '[["backgroundColor","rgba(0, 0, 0, 0.003)"],["border","none"],["boxShadow","inset 0 -2px 1px rgba(0, 0, 0, 0.03)"],["boxSizing","border-box"],["color","inherit"],["fontFamily","inherit"],["fontSize","24px"],["fontWeight","inherit"],["height","65px"],["lineHeight","1.4em"],["margin","0"],["outline","none"],["padding","16px 16px 16px 60px"],["placeholder",{"fontStyle":"italic","fontWeight":300,"color":"#e6e6e6"}],["position","relative"],["width","100%"]]'; function MurmurHash1(key, seed = 0) { var m = 3332679571, h = Math.imul(key.length, m) ^ seed; for(var i = 0, b = key.length & -4; i < b; i += 4) { h += key[i+3] << 24 | key[i+2] << 16 | key[i+1] << 8 | key[i]; h = Math.imul(h, m); h ^= h >>> 16; } switch(key.length & 3) { case 3: h += key[i+2] << 16; case 2: h += key[i+1] << 8; case 1: h += key[i]; h = Math.imul(h, m); h ^= h >>> 16; } h = Math.imul(h, m); h ^= h >>> 10; h = Math.imul(h, m); h ^= h >>> 17; return h >>> 0; }; function Cyrb53(key, seed = 0) { const A = 2654435761; const B = 1597334677; const C = 2246822507; const D = 3266489909; const E = 4294967296; const F = 2097151; let h1 = 0xdeadbeef ^ seed; let h2 = 0x41c6ce57 ^ seed; for (let index = 0, char; index < key.length; index++) { char = key.charCodeAt(index); h1 = Math.imul(h1 ^ char, A); h2 = Math.imul(h2 ^ char, B); } h1 = Math.imul(h1 ^ (h1 >>> 16), C) ^ Math.imul(h2 ^ (h2 >>> 13), D); h2 = Math.imul(h2 ^ (h2 >>> 16), C) ^ Math.imul(h1 ^ (h1 >>> 13), D); return E * (F & h2) + (h1 >>> 0); }; function SuperFastHash(key) { if (!key) {return 0} var hash = key.length, tmp, len = key.length >>> 2, p = 0; for (var i = 0; i < len; i++) { hash += key[p] | key[p+1] << 8; tmp = ((key[p+2] | key[p+3] << 8) << 11) ^ hash; hash = (hash << 16) ^ tmp; hash += hash >>> 11; p += 4; } switch(key.length & 3) { case 3: hash += key[p] | key[p+1] << 8; hash ^= hash << 16; hash ^= key[p+2] << 18; hash += hash >>> 11; break; case 2: hash += key[p] | key[p+1] << 8; hash ^= hash << 11; hash += hash >>> 17; break; case 1: hash += key[p]; hash ^= hash << 10; hash += hash >>> 1; break; } hash ^= hash << 3; hash += hash >>> 5; hash ^= hash << 4; hash += hash >>> 17; hash ^= hash << 25; hash += hash >>> 6; return hash >>> 0; };
Tests:
MurmurHash1
MurmurHash1(str);
Cyrb53
Cyrb53(str);
SuperFastHash
SuperFastHash(str);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
MurmurHash1
Cyrb53
SuperFastHash
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
MurmurHash1
487233.8 Ops/sec
Cyrb53
1876220.6 Ops/sec
SuperFastHash
473655.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark and explain what's being tested, compared options, pros and cons of each approach, and other considerations. **Benchmark Definition JSON** The benchmark definition defines three JavaScript functions: `MurmurHash1`, `Cyrb53`, and `SuperFastHash`. These functions are used to hash strings. The benchmark is run with a predefined input string `str` passed as an argument to each function. **Individual Test Cases** Each test case represents one of the three functions being compared: 1. **MurmurHash1**: This implementation by Scott Long uses a combination of bitwise operations and modular arithmetic to generate a hash value. 2. **Cyrb53**: This implementation by Eric A. Schmidt uses a different approach with bitwise operations, rotations, and shifts to generate a hash value. 3. **SuperFastHash**: This is another implementation ( likely written by John Resig) that takes advantage of the `length` property of strings in JavaScript. **Comparison Options** The benchmark compares the performance of each function: * **MurmurHash1** * **Cyrb53** * **SuperFastHash** These functions have different design goals and optimization strategies, which affect their performance: * **MurmurHash1**: Designed for speed, with an emphasis on minimizing operations. It's a simple, yet efficient implementation. * **Cyrb53**: Optimized for security, using more complex calculations to generate a hash value. While it's slower than MurmurHash1, it provides better resistance to collisions. * **SuperFastHash**: Optimized for speed and memory usage, as it reuses the `length` property of strings in JavaScript. **Pros and Cons** Here are some pros and cons of each approach: * **MurmurHash1** + Pros: Fast, simple implementation + Cons: May not be suitable for security-critical applications due to its simplicity * **Cyrb53** + Pros: Provides better resistance to collisions, suitable for security-critical applications + Cons: Slower than MurmurHash1 due to more complex calculations * **SuperFastHash** + Pros: Optimized for speed and memory usage + Cons: May not provide the same level of security as Cyrb53 **Other Considerations** When choosing a hash function, consider factors such as: * Speed: How fast do you need the hash to be? * Security: Do you require resistance to collisions or other attacks? * Memory usage: Is memory an issue for your application? In summary, MurmurHash1 is optimized for speed, Cyrb53 provides better security but at a cost in terms of performance, and SuperFastHash balances speed and memory usage. The choice ultimately depends on the specific requirements of your application.
Related benchmarks:
1A theming lodash merge vs spread
Hashing stuff
indexOf > -1 x indexOf != -1
set.add vs array.push maan
Comments
Confirm delete:
Do you really want to delete benchmark?