Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Deep object equalA / equalB / lodash isEqual /equalIterative
(version: 0)
Compares deeply two objects
Comparing performance of:
Deep equalA vs Deep equalB vs Deep equalIterative vs lodash isEqual
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> const a = { a: 123, b: true, c: 'abcd', d: [ 1, 2, 3, { t: 'test', k: [{}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ], data: { "\u0049\u0044": 915551, "\u0042\u006f\u0072\u0065": 3.25, "\u004d\u0053\u0052\u0050": 100000, "\u0059\u0065\u0061\u0072": 2059, "\u0049\u0073\u004e\u0065\u0077\u0037": true, "\u0049\u0073\u0053\u0055\u0056\u0037\u0037": true, "\u004d\u0061\u0078\u0048\u0050": 400, "\u004d\u0061\u006b\u0065\u0049\u0044": 134999, "\u004d\u0073\u0043\u006f\u0064\u0065": "\u0056\u004f\u004c\u004e\u0041\u0030\u0053", "\u0053\u0074\u0072\u006f\u006b\u0065\u0031\u0032\u0033": 3.69, "\u0057\u0065\u0069\u0067\u0068\u0074": 4993, "\u0043\u006c\u0061\u0073\u0073\u0049\u0044": 5, "\u0049\u006e\u0076\u006f\u0069\u0063\u0065": 68338, "\u004d\u006f\u0064\u0065\u006c\u0049\u0044": 74793, "\u0053\u0068\u0069\u0070\u0070\u0069\u006e\u0067": 995, "\u0043\u0079\u006c\u0069\u006e\u0064\u0065\u0072\u0073": 4, "\u0045\u0050\u0041\u004d\u0050\u0047\u0041\u0076\u0067": 55, "\u0045\u0050\u0041\u004d\u0050\u0047\u0048\u0077\u0079": 52, "\u0043\u0061\u0074\u0065\u0067\u006f\u0072\u0079\u0049\u0044": 42, "\u0045\u0050\u0041\u004d\u0050\u0047\u0043\u0069\u0074\u0079": 58, "\u0065\u006e\u0067\u0069\u006e\u0065\u0054\u0079\u0070\u0065": 11, "\u004d\u006f\u0064\u0065\u006c\u004e\u0075\u006d\u0062\u0065\u0072": "\u0058\u0043\u0039\u0030\u0054\u0038\u0052\u0037\u0037\u0037", "\u0059\u0065\u0061\u0072\u0044\u0069\u0073\u0070\u006c\u0061\u0079": "\u0032\u0030\u0032\u0030", "\u0044\u0069\u0073\u0070\u006c\u0061\u0063\u0065\u006d\u0065\u006e\u0074": 2, "\u0045\u006c\u0065\u0063\u0074\u0072\u0069\u0063\u0052\u0061\u006e\u0067\u0065": 18, "\u0049\u0073\u0032\u0057\u0068\u0065\u0065\u006c\u0044\u0072\u0069\u0076\u0065": false, "\u0053\u0075\u0062\u0063\u0061\u0074\u0065\u0067\u006f\u0072\u0079\u0049\u0044": 20, "\u0053\u0068\u006f\u0072\u0074\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u0069\u006f\u006e": "\u0034\u0044\u0020\u0057\u0041\u0047\u004f\u004e\u0020\u0054\u0038\u0020\u0048\u0059\u0042\u0052\u0049\u0044\u0020\u0052\u002d\u0044\u0045\u0053\u0049\u0047\u004e\u0020\u0041\u0057\u0044", "\u0047\u0072\u006f\u0073\u0073\u0056\u0065\u0068\u0069\u0063\u006c\u0065\u0057\u0065\u0069\u0067\u0068\u0074\u0052\u0061\u0074\u0069\u006e\u0067": 6060 } }; const b = { a: 123, b: true, c: 'abcd', d: [ 1, 2, 3, { t: 'test', k: [{}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ], data: { "\u0049\u0044": 915551, "\u0042\u006f\u0072\u0065": 3.25, "\u004d\u0053\u0052\u0050": 100000, "\u0059\u0065\u0061\u0072": 2059, "\u0049\u0073\u004e\u0065\u0077\u0037": true, "\u0049\u0073\u0053\u0055\u0056\u0037\u0037": true, "\u004d\u0061\u0078\u0048\u0050": 400, "\u004d\u0061\u006b\u0065\u0049\u0044": 134999, "\u004d\u0073\u0043\u006f\u0064\u0065": "\u0056\u004f\u004c\u004e\u0041\u0030\u0053", "\u0053\u0074\u0072\u006f\u006b\u0065\u0031\u0032\u0033": 3.69, "\u0057\u0065\u0069\u0067\u0068\u0074": 4993, "\u0043\u006c\u0061\u0073\u0073\u0049\u0044": 5, "\u0049\u006e\u0076\u006f\u0069\u0063\u0065": 68338, "\u004d\u006f\u0064\u0065\u006c\u0049\u0044": 74793, "\u0053\u0068\u0069\u0070\u0070\u0069\u006e\u0067": 995, "\u0043\u0079\u006c\u0069\u006e\u0064\u0065\u0072\u0073": 4, "\u0045\u0050\u0041\u004d\u0050\u0047\u0041\u0076\u0067": 55, "\u0045\u0050\u0041\u004d\u0050\u0047\u0048\u0077\u0079": 52, "\u0043\u0061\u0074\u0065\u0067\u006f\u0072\u0079\u0049\u0044": 42, "\u0045\u0050\u0041\u004d\u0050\u0047\u0043\u0069\u0074\u0079": 58, "\u0065\u006e\u0067\u0069\u006e\u0065\u0054\u0079\u0070\u0065": 11, "\u004d\u006f\u0064\u0065\u006c\u004e\u0075\u006d\u0062\u0065\u0072": "\u0058\u0043\u0039\u0030\u0054\u0038\u0052\u0037\u0037\u0037", "\u0059\u0065\u0061\u0072\u0044\u0069\u0073\u0070\u006c\u0061\u0079": "\u0032\u0030\u0032\u0030", "\u0044\u0069\u0073\u0070\u006c\u0061\u0063\u0065\u006d\u0065\u006e\u0074": 2, "\u0045\u006c\u0065\u0063\u0074\u0072\u0069\u0063\u0052\u0061\u006e\u0067\u0065": 18, "\u0049\u0073\u0032\u0057\u0068\u0065\u0065\u006c\u0044\u0072\u0069\u0076\u0065": false, "\u0053\u0075\u0062\u0063\u0061\u0074\u0065\u0067\u006f\u0072\u0079\u0049\u0044": 20, "\u0053\u0068\u006f\u0072\u0074\u0044\u0065\u0073\u0063\u0072\u0069\u0070\u0074\u0069\u006f\u006e": "\u0034\u0044\u0020\u0057\u0041\u0047\u004f\u004e\u0020\u0054\u0038\u0020\u0048\u0059\u0042\u0052\u0049\u0044\u0020\u0052\u002d\u0044\u0045\u0053\u0049\u0047\u004e\u0020\u0041\u0057\u0044", "\u0047\u0072\u006f\u0073\u0073\u0056\u0065\u0068\u0069\u0063\u006c\u0065\u0057\u0065\u0069\u0067\u0068\u0074\u0052\u0061\u0074\u0069\u006e\u0067": 6060 } }; const equalA = (a, b) => { if (a === b) return true; if (a && b && typeof a === 'object' && typeof b === 'object') { if (a.constructor !== b.constructor) return false; let length, index; if (Array.isArray(a)) { length = a.length; if (length !== b.length) return false; index = length; while (index--) { if (!equalA(a[index], b[index])) return false; } return true; } const keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; index = length; while (index--) { const key = keys[index]; if (!equalA(a[key], b[key])) return false; } return true; } return false; }; const equalB = (a, b) => { if (a === b) return true; if (a && b && typeof a === 'object' && typeof b === 'object') { if (a.constructor !== b.constructor) return false; let length, index; if (Array.isArray(a)) { length = a.length; if (length !== b.length) return false; index = length; while (index--) { if (!equalB(a[index], b[index])) return false; } return true; } const keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; index = length; while (index--) { if (!equalB(a[keys[index]], b[keys[index]])) return false; } return true; } return false; }; const equalIterative = (a, b) => { const arr = [[a, b]]; let length, i, key, keys; let cA, cB; for (let index = 0; index >= 0; --index) { [cA, cB] = arr[index]; if (cA === cB) continue; if (cA && cB && typeof cA === 'object' && typeof cB === 'object') { if (cA.constructor !== cB.constructor) return false; if (Array.isArray(cA)) { length = cA.length; if (length !== cB.length) return false; for (i = length; i >= 0; --i) { if (cA[i] === cB[i]) continue; arr[index++] = [cA[i], cB[i]]; } continue; } keys = Object.keys(cA); length = keys.length; if (length !== Object.keys(cB).length) return false; for (i = length; i >= 0; --i) { key = keys[i]; if (cA[key] === cB[key]) continue; arr[index++] = [cA[i], cB[i]]; } continue; } return false; } return true; }; </script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Tests:
Deep equalA
equalA(a, b);
Deep equalB
equalB(a, b);
Deep equalIterative
equalIterative(a,b);
lodash isEqual
_.isEqual(a,b)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Deep equalA
Deep equalB
Deep equalIterative
lodash isEqual
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):
The task is to determine which implementation of equality checking, `equalA`, `equalB`, or `equalIterative`, performs best among the provided benchmark results. Based on the latest benchmark result: | Test Name | Executions Per Second | | --- | --- | | Deep equalIterative | 1466478.5 | | Deep equalB | 520656.53125 | | Deep equalA | 514780.5 | | lodash isEqual | 143030.203125 | `equalIterative` performs the best with an execution rate of 1466478.5 executions per second, significantly outperforming the other implementations. ```markdown # Benchmark Results ## Test Name: Deep equalIterative - Executions Per Second: 1466478.5 ## Conclusion The `equalIterative` function performs the best among the provided benchmark results. ```
Related benchmarks:
fast_deep_equal - lodash.isEqual test567l898978666
Deep object equalA / equalB / lodash isEqual /equalIterative fix
Lodash.isEqual vs Array.join() Equality Comparison for Shallow Array of integers.
Lodash.isEqual vs ES6 Sets Equality Comparison for Shallow Array of numbers.
Comments
Confirm delete:
Do you really want to delete benchmark?