Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash isEqual test 2
(version: 0)
Test on isEqual performance
Comparing performance of:
_.isEqual Level 1 vs JSON.stringify Level 1 vs _.isEqual Level 2 vs JSON.stringify Level 2 vs _.isEqual Level 3 vs JSON.stringify Level 3
Created:
7 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 } } };
Tests:
_.isEqual Level 1
_.isEqual(window.foo1, window.bar1)
JSON.stringify Level 1
2 === 2
_.isEqual Level 2
_.isEqual(window.foo2, window.bar2)
JSON.stringify Level 2
JSON.stringify(window.foo2) === JSON.stringify(window.bar2);
_.isEqual Level 3
_.isEqual(window.foo3, window.bar3)
JSON.stringify Level 3
JSON.stringify(window.foo3) === JSON.stringify(window.bar3);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
_.isEqual Level 1
JSON.stringify Level 1
_.isEqual Level 2
JSON.stringify Level 2
_.isEqual Level 3
JSON.stringify Level 3
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):
I'll break down what's being tested, compared, and the pros/cons of different approaches. **What is being tested?** MeasureThat.net is testing the performance of `_.isEqual` from Lodash library. The test cases cover three levels of nested objects: 1. Level 1: Two identical objects with one level of nesting (`foo1` and `bar1`) 2. Level 2: Two identical objects with two levels of nesting (`foo2` and `bar2`) 3. Level 3: Two identical objects with three levels of nesting (`foo3` and `bar3`) The test also includes a simple comparison using the `===` operator on stringified versions of the objects. **What options are compared?** In this benchmark, only two options are being compared: 1. Lodash's `_isEqual` function 2. A simple `===` operator comparison **Pros and Cons:** **Lodash's `_isEqual` function:** Pros: * Handles nested objects recursively * Can be used to compare complex data structures * Part of a well-maintained library with a wide range of features Cons: * May have performance overhead due to the recursive nature of the comparison * Requires an external dependency (Lodash) **Simple `===` operator comparison:** Pros: * Fast and lightweight * Does not require any external dependencies Cons: * Only works for primitive types or stringified versions of objects * Does not handle nested objects recursively * May lead to false positives if the objects being compared are not exactly equal **Other considerations:** The benchmark also includes a comparison using `JSON.stringify`, which can be useful in certain situations, such as when comparing JSON data. However, this approach may not work well for all types of data and may lead to performance issues due to the overhead of stringifying objects. **Lodash library and its purpose:** Lodash is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, object transformation, and functional programming. The `_isEqual` function is specifically designed to compare two values for equality, handling nested objects and arrays recursively. If you're not familiar with Lodash, it's worth exploring its documentation and examples to learn more about the library and its features. **Special JS feature or syntax:** There are no special JavaScript features or syntax used in this benchmark. The code is straightforward and uses only standard JavaScript constructs. Other alternatives to MeasureThat.net include: * Benchmarking libraries like Benchmark.js, which provide a simple way to write benchmarks using Node.js. * Online testing platforms like jsPerf, which allow you to test your code's performance in a head-to-head format against others.
Related benchmarks:
Lodash (v4.17.15) isEqual test
Lodash isEqual compare with custom deepEqual in compare objects
Lodash isEqual test vs strict equality check
Lodash isEqual Array of Objects test
Lodash isEqual compare with custom deepEqual in compare objects 1
Comments
Confirm delete:
Do you really want to delete benchmark?