Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash isEqual test with big objects
(version: 0)
Test on isEqual performance
Comparing performance of:
_.isEqual Level 3 vs JSON.stringify Level 3 vs object test
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:
// 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 } } }; // window.test1 = { "traffic": "POPUP", "targeting": { "BASE": { "adultFilters": [ "ADULT", "NON_ADULT" ], "deviceFilters": { "devices": [ "MOBILE" ], "networks": { "type": "ALL" }, "desktopOses": [], "mobileOses": [ { "os": "ANDROID_PHONE", "version": { "min": "MIN", "max": "MAX" } }, { "os": "IOS_TABLET", "version": { "min": "MIN", "max": "MAX" } }, { "os": "OTHER", "version": { "min": "MIN", "max": "MAX" } }, { "os": "ANDROID_TABLET", "version": { "min": "MIN", "max": "MAX" } }, { "os": "IOS_PHONE", "version": { "min": "MIN", "max": "MAX" } } ], "desktopBrowsers": [], "mobileBrowsers": [ "FACEBOOK", "FIREFOX", "CHROME", "SAFARI", "OPERA", "UC_BROWSER", "ANDROID", "OTHER", "SAMSUNG" ] } }, "GEO": { "country": { "code": "US" } } } } window.test2 = { "traffic": "POPUP", "targeting": { "BASE": { "adultFilters": [ "ADULT", "NON_ADULT" ], "deviceFilters": { "devices": [ "MOBILE" ], "networks": { "type": "ALL" }, "desktopOses": [], "mobileOses": [ { "os": "ANDROID_PHONE", "version": { "min": "MIN", "max": "MAX" } }, { "os": "IOS_TABLET", "version": { "min": "MIN", "max": "MAX" } }, { "os": "OTHER", "version": { "min": "MIN", "max": "MAX" } }, { "os": "ANDROID_TABLET", "version": { "min": "MIN", "max": "MAX" } }, { "os": "IOS_PHONE", "version": { "min": "MIN", "max": "MAX" } } ], "desktopBrowsers": [], "mobileBrowsers": [ "FACEBOOK", "FIREFOX", "CHROME", "SAFARI", "OPERA", "UC_BROWSER", "ANDROID", "OTHER", "SAMSUNG" ] } }, "GEO": { "country": { "code": "US" } } } }
Tests:
_.isEqual Level 3
_.isEqual(window.foo3, window.bar3)
JSON.stringify Level 3
JSON.stringify(window.foo3) === JSON.stringify(window.bar3);
object test
_.isEqual(window.test1, window.test2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
_.isEqual Level 3
JSON.stringify Level 3
object test
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
_.isEqual Level 3
1281163.0 Ops/sec
JSON.stringify Level 3
6630256.0 Ops/sec
object test
186475.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Overview** The benchmark is designed to measure the performance of two functions: `_.isEqual` from Lodash and the custom implementation using JSON string comparison. The test cases are created to compare objects with different structures, including nested objects. **Test Cases** There are three test cases: 1. **_.isEqual Level 3**: This test case compares two objects at depth 3 (`window.foo3` and `window.bar3`). These objects have the same structure, but their values are slightly different. 2. **JSON.stringify Level 3**: This test case uses JSON stringification to compare the objects. It converts both objects to strings and then compares them for equality. 3. **object test**: This test case compares two objects (`window.test1` and `window.test2`) that have a similar structure, but with some differences. **Lodash Library** The Lodash library is used in the first test case (`_.isEqual Level 3`). Lodash is a popular JavaScript utility library that provides a wide range of functions for tasks like array manipulation, object manipulation, and more. In this case, `_.isEqual` is used to compare two objects for equality. **JSON Stringification** The second test case uses JSON stringification to compare the objects. This method converts both objects to strings using the `JSON.stringify()` function and then compares them for equality. **Custom Implementation** The third test case uses a custom implementation to compare the objects. Instead of using Lodash's `_.isEqual`, it directly compares the objects using the `===` operator. **Benchmark Results** The latest benchmark results show that: * The `_.isEqual Level 3` test case is the slowest, with an execution rate of approximately 1770133.75 executions per second. * The `JSON.stringify Level 3` test case is faster, with an execution rate of approximately 932815.8125 executions per second. * The `object test` is the fastest, with an execution rate of approximately 170903.03125 executions per second. Overall, the results suggest that using Lodash's `_.isEqual` function is slower than the custom implementation and JSON stringification for deep object comparisons. However, the differences are relatively small, and the choice of approach may depend on specific use cases and performance requirements.
Related benchmarks:
Normal for loop vs JSON.stringify to detect Inequality for Array of Objects.
Lodash.isEqual vs JSON.stringify Equality Comparison for deep objects.
Lodash.isEqual vs JSON.stringify Equality Comparison for objects
Lodash vs. direct comparison
Lodash.isEqual vs Lodash.isEqualWith Equality Comparison for Shallow Array of Strings.
Comments
Confirm delete:
Do you really want to delete benchmark?