Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Fast deep equal
(version: 0)
Comparing performance of:
Lodash vs fast equal
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/fast-equals@3.0.0/dist/fast-equals.min.js"></script>
Script Preparation code:
// 1 level deep var data = [ { description: 'equal numbers', value1: 1, value2: 1, equal: true, }, { description: 'not equal numbers', value1: 1, value2: 2, equal: false, }, { description: 'number and array are not equal', value1: 1, value2: [], equal: false, }, { description: '0 and null are not equal', value1: 0, value2: null, equal: false, }, { description: 'equal strings', value1: 'a', value2: 'a', equal: true, }, { description: 'big object', value1: { prop1: 'value1', prop2: 'value2', prop3: 'value3', prop4: { subProp1: 'sub value1', subProp2: { subSubProp1: 'sub sub value1', subSubProp2: [ 1, 2, { prop2: 1, prop: 2 }, 4, 5, ], }, }, prop5: 1000, prop6: new Date(2016, 2, 10), }, value2: { prop5: 1000, prop3: 'value3', prop1: 'value1', prop2: 'value2', prop6: new Date('2016/03/10'), prop4: { subProp2: { subSubProp1: 'sub sub value1', subSubProp2: [ 1, 2, { prop2: 1, prop: 2 }, 4, 5, ], }, subProp1: 'sub value1', }, }, equal: true, }, ];
Tests:
Lodash
data.forEach((item) => { _.isEqual(item.value1, item.value2); });
fast equal
data.forEach((item) => { window["fast-equals"].deepEqual(item.value1, item.value2); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
fast equal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Android 16; Mobile; rv:146.0) Gecko/146.0 Firefox/146.0
Browser/OS:
Firefox Mobile 146 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
291539.3 Ops/sec
fast equal
334031.7 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 measures the performance of two different methods for comparing arrays in JavaScript: Lodash's `isEqual` function and Fast Equals library's `deepEqual` method. **Test Cases** There are two test cases: 1. **Lodash**: The first test case uses Lodash's `isEqual` function to compare each element in the `data` array with its corresponding value in another property (e.g., `value2`). This tests how well Lodash can handle arrays and nested objects. 2. **Fast Equals**: The second test case uses Fast Equals library's `deepEqual` method to compare each element in the `data` array with its corresponding value in another property. This tests how well Fast Equals can handle arrays and nested objects. **Options Compared** The two options being compared are: * Lodash's `isEqual` function * Fast Equals library's `deepEqual` method **Pros and Cons of Each Approach** **Lodash's `isEqual` Function:** Pros: * Well-maintained and widely used library * Handles arrays and nested objects well * Can be customized with various options (e.g., strict equality, partial matches) Cons: * May have performance overhead due to the use of a separate library * May not be as optimized for array comparisons as other libraries **Fast Equals Library's `deepEqual` Method:** Pros: * Optimized for array comparisons and can be faster than Lodash * Simplifies code with its concise syntax (e.g., `fast-equals(item.value1, item.value2)` instead of `_.isEqual(item.value1, item.value2)`) * Can handle arrays and nested objects efficiently Cons: * May not have the same level of customization options as Lodash * Requires an external library (Fast Equals) **Other Considerations** Both libraries are widely used and well-maintained. Fast Equals is optimized for array comparisons, which can make it a good choice for this specific benchmark. However, if you need more customization options or are already using Lodash in your project, that might be a better fit. **Library Descriptions** * **Lodash**: A popular JavaScript utility library that provides a wide range of functions for common tasks like array manipulation, object transformation, and more. * **Fast Equals**: A lightweight JavaScript library specifically designed to compare objects and arrays efficiently. It's optimized for speed and simplicity. No special JS features or syntax are being tested in this benchmark. The focus is on comparing the performance of two different libraries for a specific use case (array comparison).
Related benchmarks:
Loop perf
loop count
loop count
or vs some
or vs some 2
Comments
Confirm delete:
Do you really want to delete benchmark?