Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash isEqual vs custom deepEquals for objects v0.0.2
(version: 1)
Comparing performance of:
_.isEqual Lx1 vs deepEquals Lx1 vs _.isEqual Lx2 vs deepEquals Lx2 vs _.isEqual Lx3 vs deepEquals Lx3 vs _.isEqual Lx3same vs deepEquals Lx3same
Created:
3 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash.isequal/index.min.js"></script> <script> var deepEquals = (a, b) => // if a and b are null/undefined/exactly the same a === b || // if they are not strictly equal, they both need to be Objects (a instanceof Object && b instanceof Object && // they must have the exact same prototype chain, the closest we can do is test their constructor a.constructor === b.constructor && // using Object.keys() as other properties were tested using a.constructor === b.constructor Object.keys(a).every( (key) => // check key is defined (vs set as undefined) on both objects Object.hasOwn(b, key) && // if defined on both, check respective values deepEquals(a[key], b[key]), ) && Object.keys(b).every((key) => Object.hasOwn(a, key))); </script>
Script Preparation code:
// 1 level deep window.foo1 = { a: new Date("1 jan"), b: 2, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } }; window.bar1 = { a: window.foo1.a, b: 3, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } }; // 2 levels deep window.foo2 = { a: new Date("2 jan"), b: 2, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } }; window.bar2 = { a: window.foo2.a, b: 2, c: { a: "1", b: 3, c: { a: 1, b: 2, c: true } } }; // 3 levels deep window.foo3 = { a: new Date("3 jan"), b: 2, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } }; window.bar3 = { a: window.foo3.a, b: 2, c: { a: "1", b: 2, c: { a: 1, b: 4, c: true } } }; // 3 levels deep same window.foo3s = { a: new Date("4 jan"), b: 2, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } }; window.bar3s = { a: window.foo3s.a, b: 2, c: { a: "1", b: 2, c: { a: 1, b: 2, c: true } } };
Tests:
_.isEqual Lx1
isEqual(window.foo1, window.bar1)
deepEquals Lx1
deepEquals(window.foo1, window.bar1);
_.isEqual Lx2
isEqual(window.foo2, window.bar2)
deepEquals Lx2
deepEquals(window.foo2, window.bar2);
_.isEqual Lx3
isEqual(window.foo3, window.bar3)
deepEquals Lx3
deepEquals(window.foo3, window.bar3);
_.isEqual Lx3same
if (!isEqual(window.foo3s, window.bar3s)) throw new Error('lo: not same')
deepEquals Lx3same
if (!deepEquals(window.foo3s, window.bar3s)) throw new Error('de: not same')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
_.isEqual Lx1
deepEquals Lx1
_.isEqual Lx2
deepEquals Lx2
_.isEqual Lx3
deepEquals Lx3
_.isEqual Lx3same
deepEquals Lx3same
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
To provide an accurate analysis, I'll need to focus on the benchmark results provided. The test is called `deepEquals` or `_.isEqual`, and it's executed multiple times with different inputs (e.g., `window.foo3s` vs. `window.bar3s`) and variations (e.g., same inputs repeated, slightly modified). The goal is to determine which version of the function is faster. Here are some observations based on the provided benchmark results: 1. **Overall performance**: Chrome 102 seems to be consistently among the fastest browsers across all test runs. 2. **Variation in execution times**: For each test run, there's a noticeable variation in execution times. This could be due to factors like network latency, browser rendering time, or the complexity of the function being tested. 3. **Same inputs repeatable results**: When `window.foo3s` is repeated as an input (e.g., `deepEquals Lx1`, `deepEquals Lx2`, and `_.isEqual Lx1`), the execution times are relatively consistent across browser versions. To provide a more specific answer, I would need to know: * What's the expected performance characteristic of the test function? Is it looking for a fixed best performer or an average value? * Are there any specific browsers or platforms that stand out as particularly fast or slow? Without additional context or clarification, I'll provide a general conclusion based on the available data: Chrome 102 seems to be consistently among the fastest browsers across all test runs. However, there's still some variation in execution times between different browser versions and input variations. If you need more precise analysis or have specific questions about the benchmark results, feel free to ask!
Related benchmarks:
Lodash (v4.17.15) isEqual test
Lodash isEqual compare with custom deepEqual in compare objects
Lodash.isEqual vs JSON.stringify Equality Comparison for Object
Lodash isEqual compare with custom deepEqual in compare objects 1
Comments
Confirm delete:
Do you really want to delete benchmark?