Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash isEqual compare with custom deepEqual in compare objects
Test on isEqual performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 128
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
_.isEqual Level 1
528725.6 Ops/sec
deepEquals Level 1
1310684.2 Ops/sec
_.isEqual Level 2
330182.3 Ops/sec
deepEquals Level 2
1018092.5 Ops/sec
_.isEqual Level 3
248237.5 Ops/sec
deepEquals Level 3
825000.6 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script> <script> function deepEquals(x, y, exceptionName) { if (x === y) { return true; // if both x and y are null or undefined and exactly the same } else if (!(x instanceof Object) || !(y instanceof Object)) { return false; // if they are not strictly equal, they both need to be Objects } else if (x.constructor !== y.constructor) { // they must have the exact same prototype chain, the closest we can do is // test their constructor. return false; } else { for (const p in x) { if (!x.hasOwnProperty(p)) { continue; // other properties were tested using x.constructor === y.constructor } if (!y.hasOwnProperty(p)) { return false; // allows to compare x[ p ] and y[ p ] when set to undefined } if (x[p] === y[p] || (!!exceptionName && p === exceptionName)) { continue; // if they have the same strict value or identity then they are equal } if (typeof x[p] !== 'object') { return false; // Numbers, Strings, Functions, Booleans must be strictly equal } if (!deepEquals(x[p], y[p])) { return false; } } for (const p in y) { if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) { return false; } } return true; } } </script>
Script Preparation code:
// 1 level deep window.foo1 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar1 = { a: 1, b: 3, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; // 2 levels deep window.foo2 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar2 = { a: 1, b: 2, c: { a: 1, b: 3, c: { a: 1, b: 2 } } }; // 3 levels deep window.foo3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 4 } } };
Tests:
_.isEqual Level 1
_.isEqual(window.foo1, window.bar1)
deepEquals Level 1
deepEquals(window.foo1, window.bar1);
_.isEqual Level 2
_.isEqual(window.foo2, window.bar2)
deepEquals Level 2
deepEquals(window.foo2, window.bar2);
_.isEqual Level 3
_.isEqual(window.foo3, window.bar3)
deepEquals Level 3
deepEquals(window.foo3, window.bar3);