Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash.isEqual vs JSON.stringify Equality Comparison for More Complicated Arrays of 1 object each
Test on isEqual performance
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/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
_.isEqual
225258.5 Ops/sec
JSON.stringify
206861.6 Ops/sec
JSON.stringify with sorted keys
253263.8 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
// Test data setup window.fills1 = [ { fill: "#FF5733", type: "SOLID", blendMode: "normal", visible: true, imgUrl: "", scaleFactor: 1, scaleMode: "FIT", uvTransform: { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }, color: { r: 255, g: 87, b: 51, a: 1 } } ]; window.fills2 = [ { fill: "#FF5733", type: "SOLID", blendMode: "multiply", // Different value here visible: true, imgUrl: "", scaleFactor: 1, scaleMode: "FIT", uvTransform: { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }, color: { r: 255, g: 87, b: 51, a: 1 } } ]; window.fills3 = JSON.parse(JSON.stringify(window.fills1));
Tests:
_.isEqual
const result12 = _.isEqual(window.fills1, window.fills2); const result13 = _.isEqual(window.fills1, window.fills3); const result23 = _.isEqual(window.fills2, window.fills3); console.log(result12, result13, result23);
JSON.stringify
const result12 = JSON.stringify(window.fills1) === JSON.stringify(window.fills2); const result13 = JSON.stringify(window.fills1) === JSON.stringify(window.fills3); const result23 = JSON.stringify(window.fills2) === JSON.stringify(window.fills3); console.log(result12, result13, result23);
JSON.stringify with sorted keys
const sortedStringify = (obj) => JSON.stringify(obj, Object.keys(obj || {}).sort()); const result12 = sortedStringify(window.fills1) === sortedStringify(window.fills2); const result13 = sortedStringify(window.fills1) === sortedStringify(window.fills3); const result23 = sortedStringify(window.fills2) === sortedStringify(window.fills3); console.log(result12, result13, result23);