Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash isEqual vs object-hash compare hashes (md5 test)
(version: 3)
Comparing performance of:
stringify md5 vs #hashes vs isEqual (objects)
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/object-hash@3.0.0/dist/object_hash.min.js"></script>
Script Preparation code:
window.testObj1 = { _id: "6241bf1d424cff26638d7a5a", index: 0, guid: "a5764c7c-e6c4-45a8-90c5-975c06d8a76f", isActive: true, balance: "$1,378.60", picture: "http://placehold.it/32x32", age: 28, eyeColor: "green", name: "Prince Farrell", gender: "male", company: "PAPRIKUT", email: "princefarrell@paprikut.com", phone: "+1 (977) 406-2526", address: "872 Garden Street, Stockdale, Delaware, 9634", about: "Laborum minim mollit qui eiusmod veniam est. In labore enim cillum enim cillum magna dolor magna amet id ex ea nulla nostrud. Ipsum est laborum et consectetur pariatur nostrud magna. Nulla pariatur cillum et proident labore ad ipsum deserunt.\r\n", registered: "2021-07-31T02:37:28 -03:00", latitude: -83.931425, longitude: 41.147296, tags: [ "irure", "sint", "adipisicing", "nostrud", "sint", "in", "magna" ], friends: [{ id: 0, name: "Owen Price" }, { id: 1, name: "Cain Key" }, { id: 2, name: "Josie Hatfield" } ], greeting: "Hello, Prince Farrell! You have 10 unread messages.", favoriteFruit: "banana" }; window.testObj2 = { _id: "5464564563456356", index: 0, guid: "a5764c7c-e6c4-45a8-90c5-975c556506d8a76f", isActive: false, balance: "$1,378.60", picture: "http://placehold.it/32x32", age: 28, eyeColor: "red", name: "Prince Farrell", gender: "male", company: "PAPRIKUT", email: "princefarrell@paprikut.com", phone: "+1 (977) 406-2526", address: "872 Garden Street, Stockdale, Delaware, 9634", about: "Laborum minim fffff qui eiusmod veniam est. In labore enim cillum enim cillum magna dolor magna amet id ex ea nulla nostrud. Ipsum est laborum et consectetur pariatur nostrud magna. Nulla pariatur cillum et proident labore ad ipsum deserunt.\r\n", registered: "2021-07-31T02:37:28 -03:00", latitude: -83.931425, longitude: 41.147296, tags: [ "irure", "sint", "adipisicing", "nostrud", "sint", "in", "magna", "test" ], friends: [{ id: 0, name: "Owen Price" }, { id: 1, name: "Cain Key" }, ], greeting: "Hello, Prince Farrell! You have 10 unread messages.", favoriteFruit: "potato" }
Tests:
stringify md5
testObj2.age = Math.random(); testObj2.index = Math.random(); const testObjHash1 = objectHash(JSON.stringify(testObj1), {algorithm: 'md5'}); const testObjHash2 = objectHash(JSON.stringify(testObj2), {algorithm: 'md5'}); testObj1 === testObj2;
#hashes
testObj2.age = Math.random(); testObj2.index = Math.random(); const testObjHash1 = objectHash(testObj1, {algorithm: 'md5'}); const testObjHash2 = objectHash(testObj2, {algorithm: 'md5'}); testObj1 === testObj2;
isEqual (objects)
testObj2.age = Math.random(); testObj2.index = Math.random(); _.isEqual(testObj1, testObj2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
stringify md5
#hashes
isEqual (objects)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
stringify md5
21702.3 Ops/sec
#hashes
4458.5 Ops/sec
isEqual (objects)
2543453.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring performance of JavaScript functions and libraries is an essential part of software development. I'll break down the benchmark and its results, explaining what's being tested and the pros and cons of each approach. **Benchmark Overview** The benchmark consists of three individual test cases: 1. `stringify md5`: Compares two objects (`testObj1` and `testObj2`) after modifying their properties using `Math.random()`. 2. `#hashes`: Compares two objects (`testObj1` and `testObj2`) without modifying their properties. 3. `isEqual (objects)`: Compares the equality of two objects (`testObj1` and `testObj2`) directly. **Test 1: `stringify md5`** This test case compares the modified objects after stringifying them using `JSON.stringify()` and then hashing them with `objectHash` library (version 3.0.0) using the MD5 algorithm. * The purpose of this test is to evaluate the performance of the `objectHash` library when dealing with modified objects. * **Pros:** * This test case helps identify performance issues related to hashing and comparing objects after modifications. * **Cons:** * It may not accurately represent real-world scenarios where objects are rarely modified. **Test 2: `#hashes`** This test case compares the two original objects (`testObj1` and `testObj2`) without modifying their properties. It uses the same `objectHash` library (version 3.0.0) with the MD5 algorithm to hash both objects. * The purpose of this test is to evaluate the performance of the `objectHash` library when dealing with unmodified objects. * **Pros:** * This test case helps identify performance issues related to hashing and comparing original objects. * **Cons:** * It may not accurately represent real-world scenarios where objects are modified. **Test 3: `isEqual (objects)`** This test case compares the equality of the two objects (`testObj1` and `testObj2`) directly using the `_.isEqual()` function from Lodash library (version 4.17.21). * The purpose of this test is to evaluate the performance of the `_.isEqual()` function when comparing equal or unequal objects. * **Pros:** * This test case helps identify performance issues related to comparing objects directly. * **Cons:** * It may not accurately represent real-world scenarios where object equality checks are used with modifications. **Benchmark Results** The benchmark results show the execution time per second for each test case: * `stringify md5`: 762.082 executions per second (Chrome 120, Desktop, Linux) * `#hashes`: 9864.78515625 executions per second (Chrome 120, Desktop, Linux) * `isEqual (objects)`: 2446.115234375 executions per second (Chrome 120, Desktop, Linux) **Conclusion** The results indicate that: * The performance of the `objectHash` library is optimal when dealing with modified objects (`stringify md5`). * The performance of the `objectHash` library is slower than expected when dealing with unmodified objects (`#hashes`). * The performance of the Lodash `_isEqual()` function is good for comparing equal or unequal objects directly. Keep in mind that benchmark results may vary depending on the specific hardware, software configurations, and test environments used.
Related benchmarks:
Hash vs insert
lodash size vs native Object.keys length vs JSON string
hash-sum (2.0) vs object-hash (3.0)
hash-sum (2.0) vs object-hash (3.0) (BIG and diff order)
Comments
Confirm delete:
Do you really want to delete benchmark?