Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs vanila 3.2
(version: 0)
Comparing performance of:
Lodash vs Vanila
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function makeid(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for ( var i = 0; i < length; i++ ) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } function uniqByTitle(arr) { return [...arr.reduce((items, item) => { if (!items.has(item.title)) { items.set(item.title, item); } return items; }, new Map()).values()]; } var arr = []; for(var i = 0; i < 100000; i++){ arr.push({ title: makeid(20), }); }
Tests:
Lodash
_.uniqBy(arr, (item => item.title));
Vanila
uniqByTitle(arr)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
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):
Let's dive into the explanation of the benchmark. **Benchmark Overview** The benchmark compares the performance of two approaches: using Lodash and implementing it manually (vanila). The test case creates an array of 100,000 objects with unique titles generated randomly. **Options Compared** There are two options being compared: 1. **Lodash**: A popular JavaScript utility library that provides a wide range of functions for various tasks, such as data manipulation, string manipulation, and more. 2. **Vanila**: Implementing the `uniqBy` function manually without using any external libraries. **Pros and Cons** **Lodash:** Pros: * Provides a robust and efficient implementation of the `uniqBy` function, reducing the chance of errors and optimization issues. * Offers a large community-driven library with extensive documentation and testing. Cons: * Requires including an additional library in the benchmark, which may affect the overall size and loading time of the test page. * May introduce dependencies that could impact the benchmark's results. **Vanila:** Pros: * Eliminates the need for an external library, reducing the benchmark's overhead and simplifying maintenance. * Allows developers to understand the implementation details and optimize it specifically for their use case. Cons: * Requires manual implementation of the `uniqBy` function, which may introduce errors or optimization issues if not done correctly. * May result in less efficient code due to the lack of optimization techniques used in Lodash. **Library: Lodash** Lodash is a popular JavaScript library developed by Isaac Schlueter. It provides over 100 functions for various tasks, such as: * Array manipulation * Object manipulation * String manipulation * Utility functions The `uniqBy` function, specifically, removes duplicate elements from an array based on a unique property value. **Special JS Feature/ Syntax** There is no specific JavaScript feature or syntax mentioned in the benchmark. However, it's worth noting that some modern browsers support features like WebAssembly (WASM), which can significantly impact performance. If the test case were to include WASM-related functionality, it might affect the results. **Other Alternatives** If you're interested in exploring alternative libraries for data manipulation tasks, here are a few options: * **PunyCDN**: A small and lightweight library that provides a subset of Lodash's functions. * **Underscore.js**: Another popular JavaScript utility library that offers similar functionality to Lodash. * **Ramda**: A functional programming library that provides a different approach to data manipulation tasks. Keep in mind that each library has its strengths and weaknesses, and the choice ultimately depends on your specific use case and performance requirements.
Related benchmarks:
reduce-vs-uniqBy_2
Lodash uniqBy vs Set
Unique lodash vs vanilla
Create an array with unique values - Javascript Array.reduce/Array.indexOf vs Lodash Uniq
_.uniqWith(arr, _.isEqual).length vs new Set(arr).size 1
Comments
Confirm delete:
Do you really want to delete benchmark?