Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object comparison
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
lodash
879226.5 Ops/sec
underscore
2809861.2 Ops/sec
JSON.stringify() JSON.st
937577.7 Ops/sec
isEqualShallow()
82496080.0 Ops/sec
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> <script> var underscore = _.noConflict(); </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.5.0/lodash.min.js"></script> <script> var lodash = _.noConflict(); </script> <script> Benchmark.prototype.setup = function() { var obj1 = { properties: { selectionName: null, price: { format: 'fractional', odds: null }, status: 'A', display: { displayed: 'Y', order: null }, selectionScore: { home: null, away: null }, band: { lower: 5, upper: 10 }, channels: 'ZWIP' }, result: null }; var obj2 = { properties: { selectionName: null, price: { format: 'fractional', odds: null }, status: 'A', display: { displayed: 'Y', order: null }, selectionScore: { home: null, away: null }, band: { lower: null, upper: null }, channels: 'ZWIP' }, result: null }; lodash = window.lodash; underscore = window.underscore window.isEqualShallow = function (a, b) { if (!a && !b) { return true; } if (!a && b || a && !b) { return false; } var numKeysA = 0, numKeysB = 0, key; for (key in b) { numKeysB++; if (/* !isPrimitive(b[key]) || */ !a.hasOwnProperty(key) || (a[key] !== b[key])) { // console.log(key, a, b); return false; } } for (key in a) { numKeysA++; } return numKeysA === numKeysB; } }; </script>
Tests:
lodash
window.lodash.isEqual(obj1, obj2);
underscore
window.underscore.isEqual(obj1, obj2);
JSON.stringify() JSON.st
JSON.stringify(obj1) == JSON.stringify(obj2);
isEqualShallow()
window.isEqualShallow(obj1, obj2);