Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash vs un
(version: 0)
Comparing performance of:
underscore vs lodash vs vanila
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js'></script> <script type="text/javascript"> window.lodash = _; _ = null; </script> <script src='https://cdn.jsdelivr.net/npm/underscore@1.12.1/underscore-min.js'></script> <script type="text/javascript"> window.underscore = _; _ = null; </script>
Script Preparation code:
function arrayDiff(a, b) { const setB = new Set(b); return a.filter(x => !setB.has(x)); } var array1 = [155738, 215577, 215613, 215535, 215765, 215488, 215778, 215641, 215750, 215476, 215565, 215677, 215631, 215655, 215552, 215544, 215642, 215529, 215533, 215531, 215615, 215686, 215512, 215584, 157618, 215586, 215692, 215653, 215483, 215599, 215542, 215473, 215450, 215459, 215651, 215629, 215463, 215567, 215645, 215788, 215787, 215779, 215766, 215751, 215693, 215688, 215687, 215678, 215656, 215654, 215652, 215646, 215644, 215643, 215632, 215630, 215616, 215614, 157619, 215600, 155739, 215587, 215585, 215568, 215566, 215489, 215553, 215545, 215543, 215536, 215534, 215532, 215530, 215513, 215484, 215477, 215474, 215464, 215460, 215451]; var array2 = [155738, 215273, 214753, 215144, 215242, 214646, 214738, 214905, 215577, 214922, 215613, 214624, 215312, 215202, 215430, 215037, 215094, 215200, 215142, 156161, 215189, 215016, 215198, 215081, 215535, 215765, 215071, 215488, 215778, 214767, 215641, 214673, 215349, 215157, 214655, 215750, 215246, 215270, 215476, 215140, 215565, 215677, 215441, 215631, 215334, 215655, 215552, 215544, 215407, 215642, 214826, 214887, 215105, 214723, 214907, 215166, 215529];
Tests:
underscore
underscore.difference(array1, array2);
lodash
lodash.difference(array1, array2)
vanila
arrayDiff(array1, array2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
underscore
lodash
vanila
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):
**Benchmark Explanation** The provided JSON represents a JavaScript microbenchmark test case for comparing the performance of three different approaches to calculate the difference between two arrays: `underscore`, `lodash`, and a vanilla JavaScript implementation (`vanila`). **Options Compared** * **Lodash (underscore)**: The Lodash library provides a utility function `difference()` that can be used to find the difference between two arrays. * **Lodash alternative (underscore)**: This is an alternative implementation of the `difference()` function, but it's not the official one from Lodash. It seems like this test case is using a buggy or outdated version of the underscore library. * **Vanilla JavaScript (`vanila`)**: The vanilla JavaScript implementation uses a simple array filter approach to find the difference between two arrays. **Pros and Cons** ### Lodash (underscore) Pros: * Well-tested and widely used utility library. * Provides a clear and concise API for finding differences between arrays. Cons: * May have some performance overhead due to its complexity. ### Lodash alternative (underscore) Pros: None mentioned in the benchmark data Cons: The implementation seems buggy or outdated, which may lead to incorrect results or performance issues. ### Vanilla JavaScript (`vanila`) Pros: * No dependencies, making it easy to integrate and perform well. * Lightweight and simple implementation. Cons: * May not be as efficient or robust as the Lodash solution. **Other Considerations** The benchmark measures the execution frequency of each approach in a specific browser environment. This allows for an apples-to-apples comparison between the three options. ### Library: Underscore.js Underscore.js is a popular JavaScript utility library that provides functional programming helpers, including array manipulation functions like `difference()`. It's designed to be compact and performant, making it suitable for applications where speed is crucial. In this benchmark, the test case uses an older version of underscore (1.12.1) which may not have been updated with some features or optimizations since its initial release. ### Special JavaScript Features/Syntax None mentioned in the provided benchmark data. **Other Alternatives** For array differences, other libraries like `moment` or `ramda` also provide efficient solutions. However, these are not included in this specific benchmark. If you need more robust and modern approaches to array manipulation or want to explore other alternatives: * Consider using a library like `fast-levenshtein` for array comparisons. * Look into the `filter()` method for finding differences between arrays. * Use `Set` data structures for efficient lookup and filtering.
Related benchmarks:
Lodash => (Equal + sort) vs (xor): unsorted array
native intersect vs lodash intersection
Lodash union VS ES6 Set
lodash uniq vs Array.from(new Set()) vs spread new Set() vs array.filter_bigger
Comments
Confirm delete:
Do you really want to delete benchmark?