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 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Browser:
Firefox 134
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Compare two equal objects
494487.7 Ops/sec
Compare two unequal objects
538669.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);