Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Deep equal
Compares deeply two objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Compare two equal objects
1566991.9 Ops/sec
Compare two unequal objects
1688666.5 Ops/sec
HTML Preparation code:
<script> const equal = (a, b) => { if (a === b) return true; if (a && b && typeof a === 'function' && typeof b === 'function') { return a.toString() === b.toString(); } 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 (!equal(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 (!Object.prototype.hasOwnProperty.call(b, keys[index])) return false; } index = length; while (index--) { const key = keys[index]; if (!equal(a[key], b[key])) return false; } return true; } return false; }; </script>
Tests:
Compare two equal objects
const a = { a: 123, b: true, c: ()=> console.log('test'), d: [ 1, 2, 3, { t: 'test', k: [ {}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ] }; const b = { a: 123, b: true, c: ()=> console.log('test'), d: [ 1, 2, 3, { t: 'test', k: [ {}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ] }; equal(a, b);
Compare two unequal objects
const a = { a: 123, b: true, c: ()=> console.log('this is a fn call'), d: [ 1, 2, 3, { t: 'test', k: [ {}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ] }; const b = { a: 123, b: true, c: ()=> console.log('test'), d: [ 1, 2, 3, { t: 'test', k: [ {}, [9, 8, 7], {} ] }, [], {}, { a: 'text', b: false } ] }; equal(a, b);