Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash min vs Math.min (lodash 4.7.11)
(version: 0)
Comparing performance of:
_.min vs Math.min
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.7.11/lodash.min.js'></script>
Script Preparation code:
function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } var arr = []; for(var i = 0; i < 1000; i++){ arr.push({value:getRandomInt(100)}); }
Tests:
_.min
_.min(arr);
Math.min
Math.min(...arr)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.min
Math.min
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
_.min
9484.6 Ops/sec
Math.min
15358.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark definition and options being compared. **Benchmark Definition:** The benchmark is comparing two functions for finding the minimum value in an array: 1. `_.min(arr)` from Lodash library (version 4.7.11) 2. `Math.min(...arr)` Both functions take an array as input and return the smallest element in the array. **Options being compared:** * **Lodash's `_.min()`**: This function is part of the popular Lodash utility library, which provides a collection of functional programming helpers. `_.min()` uses a custom implementation to find the minimum value in the array. * **JavaScript's built-in `Math.min()`**: This is a standard JavaScript function that returns the smallest element among the values passed as arguments. **Pros and Cons:** * **Lodash's `_.min()`**: + Pros: - Often more readable and concise than using `Math.min()` - May be faster due to optimized implementation - Part of a larger utility library with other useful functions + Cons: - Additional dependency (Lodash library) - May add overhead due to the need to import and load the library * **JavaScript's built-in `Math.min()`**: + Pros: - No additional dependencies or overhead - Fast and efficient implementation - Always available without requiring additional libraries + Cons: - May require more verbose code (e.g., using `...arr` syntax) - Less readable or concise than using `_.min()` from Lodash **Library:** Lodash is a popular JavaScript utility library that provides a collection of functional programming helpers. It's often used for tasks like array manipulation, object utilities, and more. In this case, the `_.min()` function is part of the Lodash library. **Special JS feature or syntax:** There are no special features or syntaxes being tested in this benchmark. The focus is on comparing two functions with different implementations. **Other alternatives:** If you need to find the minimum value in an array without using `Math.min()` from JavaScript, other alternatives might include: * Using a custom implementation like Lodash's `_min()` function * Utilizing a library or framework that provides a similar function (e.g., Ramda, Immutable.js) * Implementing a simple loop-based approach to find the minimum value Keep in mind that these alternatives may introduce additional dependencies or overhead compared to using the built-in `Math.min()` function.
Related benchmarks:
Lodash max vs Math.max (lodash 4.7.11)
Lodash vs Math (lodash 4.17.5) arr(5000)
Lodash max vs JS Math.max (2022)
Lodash.isArray vs Array.isArray (Lodash v4.17.15)
Comments
Confirm delete:
Do you really want to delete benchmark?