Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON.stringify vs Naive deepEqual
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/146.0.0.0 Safari/537.36
Browser:
Chrome 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
yesterday
Test name
Executions per second
JSON.stringify
9561759.0 Ops/sec
Naive deepEqual
144004544.0 Ops/sec
Tests:
JSON.stringify
const data1 = { section: { id: 'test', }, block: { id: 'test', } } const data2 = { section: { id: 'testing', }, block: undefined } function isEqual(a, b) { return JSON.stringify(a) === JSON.stringify(b); } isEqual(data1, data2);
Naive deepEqual
const data1 = { section: { id: 'test', }, block: { id: 'test', } } const data2 = { section: { id: 'testing', }, block: undefined } function isEqual(a, b) { if (a != b) { return false; } if (a == b) { return true; } const hasDifferentProperties = Object.entries(a).some( ([key, value]) => { if (value == null && b[key] != null) { return true; } if (value != null && b[key] == null) { return true; } if (typeof value === 'Object') { return Object.entries(value).some(([k, v]) => v != b[key][k]); } return value != b[key]; }, ); } isEqual(data1, data2);