Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
fast Deep Equal vs JSON.stringify Equality Comparison for very large arrays of nested numbers
Test on deep equality checking performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
fast deep equals same
710.4 Ops/sec
fast deep equals similar
887.2 Ops/sec
fast deep equals different
17808730.0 Ops/sec
stringify same
29.1 Ops/sec
stringify similar
29.7 Ops/sec
stringify different
31.3 Ops/sec
Script Preparation code:
'use strict'; // do not edit .js files directly - edit src/index.jst var envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; window.fdeq = 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 instanceof Map) && (b instanceof Map)) { if (a.size !== b.size) return false; for (i of a.entries()) if (!b.has(i[0])) return false; for (i of a.entries()) if (!equal(i[1], b.get(i[0]))) return false; return true; } if ((a instanceof Set) && (b instanceof Set)) { if (a.size !== b.size) return false; for (i of a.entries()) if (!b.has(i[0])) return false; return true; } if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (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; }; window.foo = Array.from({ length: 40000 }, () => ([Math.random() * 40, Math.random() * 40])); window.foo2 = JSON.parse(JSON.stringify(window.foo.slice())); window.fox = (Array.from({ length: 10000 }, () => ([Math.random() * 40, Math.random() * 40]))).concat(JSON.parse(JSON.stringify(window.foo.slice(-30000)))); window.bar = Array.from({ length: 40000 }, () => ([Math.random() * 40, Math.random() * 40]));
Tests:
fast deep equals same
fdeq(window.foo, window.foo2);
fast deep equals similar
fdeq(window.foo, window.fox);
fast deep equals different
fdeq(window.foo, window.bar);
stringify same
JSON.stringify(window.foo) === JSON.stringify(window.foo2)
stringify similar
JSON.stringify(window.foo) === JSON.stringify(window.fox)
stringify different
JSON.stringify(window.foo) === JSON.stringify(window.bar)