Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
obj comparision
(version: 0)
obj comparision
Comparing performance of:
equals 4 vs isEqual
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
// 1 level deep window.foo1 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar1 = { a: 1, b: 3, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; // 2 levels deep window.foo2 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar2 = { a: 1, b: 2, c: { a: 1, b: 3, c: { a: 1, b: 2 } } }; // 3 levels deep window.foo3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } }; window.bar3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 4 } } }; // real world window.foo4 = { info: { clientId: 0, businessName: 'Aaron Air LLC', uniqueLocationReference: '112', country: 'AUS', address1: '1957 Pioneer Rd.', address2: 'Unit E3', city: 'Aranda', state: 'Australian Capital Territory', postcode: '19006', businessTelephone: '(267) 872-0809', url: 'http://www.aaronairhvac.com', googlePlaceId: 0, coords: { lat: 0, lng: 0 }, formationDate: null, gmbListing: { googlePlaceData: null, externalGooglePlaceId: null }, primaryCategory: 509 }, about: 'About the Business', openingHours: { regular: { applyToAll: false, notSupplied: false, mon: { status: 'closed', hours: [] }, tue: { status: 'closed', hours: [] }, wed: { status: 'closed', hours: [] }, thu: { status: 'closed', hours: [] }, fri: { status: 'closed', hours: [] }, sat: { status: 'closed', hours: [] }, sun: { status: 'closed', hours: [] } }, special: [] }, cb: { contactFirstName: 'Steve', contactLastName: 'Borell', contactEmail: 'steve@aaronair.net', contactMobileTelephone: '(267) 872-0809', contactFax: '', employeesNumber: null, paymentMethods: [], services: [ null ], socialProfileLinks: null, additionalCategories: [] }, photos: { cb: { logoUrl: '', photo1Url: '', photo2Url: '', photo3Url: '' } }, additionalData: { gmb: { attributes: [], labels: [ '' ], gmbStoreCode: '', alternativePhones: [ { countryCode: '', number: '' } ], adsPhone: [ { countryCode: '', number: '' } ], additionalCategories: [], media: [] }, facebook: { additionalCategories: [], priceRange: '', description: '' }, bing: { additionalCategories: [], description: '' }, metadata: { activeSync: { gmb: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, facebook: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, yelp: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, bing: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, appleMaps: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' } } } }, notifications: { alerts: [], sources: [ 'gmb', 'facebook', 'bing' ], selectedSources: [], paging: null, newAlertsCount: 0 } }; window.bar4 = { info: { clientId: 0, businessName: 'Aaron Air LLC', uniqueLocationReference: '112', country: 'AUS', address1: '1957 Pioneer Rd.', address2: 'Unit E3', city: 'Aranda', state: 'Australian Capital Territory', postcode: '19006', businessTelephone: '(267) 872-0809', url: 'http://www.aaronairhvac.com', googlePlaceId: 0, coords: { lat: 0, lng: 0 }, formationDate: null, gmbListing: { googlePlaceData: null, externalGooglePlaceId: null }, primaryCategory: 509 }, about: 'About the Business', openingHours: { regular: { applyToAll: false, notSupplied: false, mon: { status: 'closed', hours: [] }, tue: { status: 'closed', hours: [] }, wed: { status: 'closed', hours: [] }, thu: { status: 'closed', hours: [] }, fri: { status: 'closed', hours: [] }, sat: { status: 'closed', hours: [] }, sun: { status: 'closed', hours: [] } }, special: [] }, cb: { contactFirstName: 'Steve', contactLastName: 'Borell', contactEmail: 'steve@aaronair.net', contactMobileTelephone: '(267) 872-0809', contactFax: '', employeesNumber: null, paymentMethods: [], services: [ null ], socialProfileLinks: null, additionalCategories: [] }, photos: { cb: { logoUrl: '', photo1Url: '', photo2Url: '', photo3Url: '' } }, additionalData: { gmb: { attributes: [], labels: [ '' ], gmbStoreCode: '', alternativePhones: [ { countryCode: '', number: '' } ], adsPhone: [ { countryCode: '', number: '' } ], additionalCategories: [], media: [] }, facebook: { additionalCategories: [], priceRange: '', description: '' }, bing: { additionalCategories: [], description: '' }, metadata: { activeSync: { gmb: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, facebook: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, yelp: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, bing: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' }, appleMaps: { activeSyncEnabled: false, autoSuppressionEnabled: false, connectedItemId: null, syncStatus: '' } } } }, notifications: { alerts: [], sources: [ 'gmb', 'facebook', 'bing' ], selectedSources: [], paging: null, newAlertsCount: 0 } }; function equals(v1, v2) { function countProps(obj) { let count = 0; for (const k in obj) { if (obj.hasOwnProperty(k)) { count++; } } return count; } if (typeof v1 !== typeof v2) { return false; } if (typeof v1 === 'function') { return v1.toString() === v2.toString(); } if (v1 instanceof Object && v2 instanceof Object) { if (countProps(v1) !== countProps(v2)) { return false; } for (const k in v1) { if (!equals(v1[k], v2[k])) { return false; } } return true; } return v1 === v2; }
Tests:
equals 4
equals(window.foo4, window.bar4)
isEqual
_.isEqual(window.foo4, window.bar4)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
equals 4
isEqual
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The benchmark data appears to be related to comparing two objects, `foo4` and `bar4`, using both the native JavaScript `===` operator (equals) and the Lodash library's `isEqual` function. Here is a summary of the benchmark results: 1. The native JavaScript `===` operator: * For the test case "equals 4", the average executions per second are 8783.611328125. * For the test case "isEqual", the average executions per second are 7692.42578125. 2. The Lodash library's `isEqual` function: * Both tests have similar execution rates, with an average of around 7700-8800 executions per second. Based on these results, it appears that the native JavaScript `===` operator is slightly faster than the Lodash library's `isEqual` function for this specific test case. However, the difference is relatively small and may not be significant in most cases. It's also worth noting that the Chrome browser version used in the benchmark (86) might influence the results, as different versions of the browser can have varying performance characteristics.
Related benchmarks:
Lodash isEqual compare with custom deepEqual in compare objects
Equality test
Lodash isEqual Array of Objects test
lodash _isEqual
Comments
Confirm delete:
Do you really want to delete benchmark?