Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
es-toolkit isEqual vs hashed JSON stringify vs lodash isEqual vs fast-deep-equal
(version: 1)
Comparing performance of:
es-toolkit vs Hashed JSON.stringify vs lodash vs fast deep equal
Created:
one month ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/es-toolkit@%5E1"></script> <script> window.et = window._; </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
Script Preparation code:
const node1 = { "de_DE": { "content": { "blocks": { "1": { "children": [ "2" ], "type": "section" }, "2": { "children": [ "3" ], "type": "container" }, "3": { "children": [ "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d" ], "config": { "width": "1" }, "type": "column" }, "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d": { "children": [ "7dc9103d-8f09-5865-9482-3a1968caef48" ], "type": "bigHeading" }, "7dc9103d-8f09-5865-9482-3a1968caef48": { "config": { "value": "Hallo22223" }, "type": "text" } }, "content": [ "1" ] }, "title": "NFS-3398 – Seitentest" }, "en_US": { "content": { "blocks": { "1": { "children": [ "2" ], "type": "section" }, "1dc00c75-828a-5e26-90c1-f60b4af3bf3f": { "config": { "value": "Hello2222" }, "type": "text" }, "2": { "children": [ "3" ], "type": "container" }, "3": { "children": [ "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d" ], "config": { "width": "1" }, "type": "column" }, "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d": { "children": [ "1dc00c75-828a-5e26-90c1-f60b4af3bf3f" ], "type": "bigHeading" } }, "content": [ "1" ] }, "title": "NFS-3398 - Page Test" } }; const node2 = { "de_DE": { "content": { "blocks": { "1": { "children": [ "2" ], "type": "section" }, "2": { "children": [ "3" ], "type": "container" }, "3": { "children": [ "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d" ], "config": { "width": "1" }, "type": "column" }, "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d": { "children": [ "7dc9103d-8f09-5865-9482-3a1968caef48" ], "type": "bigHeading" }, "7dc9103d-8f09-5865-9482-3a1968caef48": { "config": { "value": "Hallo22223" }, "type": "text" } }, "content": [ "1" ] }, "title": "NFS-3398 – Seitentest" }, "en_US": { "content": { "blocks": { "1": { "children": [ "2" ], "type": "section" }, "1dc00c75-828a-5e26-90c1-f60b4af3bf3f": { "config": { "value": "Hello2222" }, "type": "text" }, "2": { "children": [ "3" ], "type": "container" }, "3": { "children": [ "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d" ], "config": { "width": "1" }, "type": "column" }, "38e06e3b-8d56-4d70-ab96-9c8d28d1de3d": { "children": [ "1dc00c75-828a-5e26-90c1-f60b4af3bf3f" ], "type": "bigHeading" } }, "content": [ "1" ] }, "title": "NFS-3398 - Page Test" } };
Tests:
es-toolkit
et.isEqual(node1, node2);
Hashed JSON.stringify
const hashContent = (str) => { let h1 = 0xdeadbeef, h2 = 0x41c6ce57; for (let i = 0, ch; i < str.length; i++) { ch = str.charCodeAt(i); h1 = Math.imul(h1 ^ ch, 2654435761); h2 = Math.imul(h2 ^ ch, 1597334677); } h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507); h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909); h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507); h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909); return h2.toString(36).padStart(7, '0') + h1.toString(36).padStart(7, '0'); }; hashContent(JSON.stringify(node1)) === hashContent(JSON.stringify(node2));
lodash
_.isEqual(node1, node2);
fast deep equal
function equal(a, b) { if (a === b) return true; if (a && b && typeof a == 'object' && typeof b == 'object') { if (a.constructor !== b.constructor) return false; var length, i, keys; if (Array.isArray(a)) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false; return true; } if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; for (i = length; i-- !== 0;) { var key = keys[i]; if (!equal(a[key], b[key])) return false; } return true; } // true if both NaN, false otherwise return a!==a && b!==b; }; equal(node1, node2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
es-toolkit
Hashed JSON.stringify
lodash
fast deep equal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.3 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
es-toolkit
126033.6 Ops/sec
Hashed JSON.stringify
117241.4 Ops/sec
lodash
154504.3 Ops/sec
fast deep equal
528921.5 Ops/sec
Related benchmarks:
my deep clone - lodash vs ramda vs json
lodash clonedeep vs json.parse(stringify()) vs recursivecopy v2
js-diff vs deep-diff - Diff creation
Lodash.isEqual vs JSON.stringify Equality Comparison for markup object ver2.
JSON.stringify fork, larger item
deep-diff vs json-fast-patch
json-diff-patch vs fast-json-patch
es-toolkit isEqual vs JSON stringify
es-toolkit isEqual vs JSON stringify vs lodash isEqual
Comments
Confirm delete:
Do you really want to delete benchmark?