Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Native vs Lodash vs Lodash FP
(version: 0)
Comparing performance of:
Native vs Lodash vs Lodash FP
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)'></script> var fp = _.noConflict();
Script Preparation code:
var fp = _.noConflict(); var array = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; var reducer = (r, x) => r + x;
Tests:
Native
array.reduce(reducer, '');
Lodash
_.reduce(array, reducer, '');
Lodash FP
fp.reduce(reducer, '', array);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native
Lodash
Lodash FP
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native
3814568.8 Ops/sec
Lodash
3102977.5 Ops/sec
Lodash FP
2470185.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided JSON represents a benchmark test comparing the performance of three approaches: native JavaScript, Lodash (a popular utility library), and Lodash's functional programming (FP) variant. **Benchmark Definition and Options Compared** The benchmark definition is defined by the `Script Preparation Code` section in the main JSON object. The options compared are: 1. **Native**: The built-in JavaScript method `Array.prototype.reduce()`. 2. **Lodash**: The `_reduce()` function from Lodash, which wraps the native JavaScript implementation. 3. **Lodash FP**: A variant of the `_reduce()` function that uses functional programming principles, created by setting `_noConflict()` to return a new version of the function, ensuring that it does not interfere with the native JavaScript `Array.prototype.reduce()` method. **Pros and Cons of Each Approach** 1. **Native**: The built-in JavaScript implementation is likely optimized for performance and may have better cache locality, making it a good baseline. * Pros: Native implementation is likely to be the fastest, as it's tightly coupled with the JavaScript engine. * Cons: May not provide the same level of readability or expressiveness as other options. 2. **Lodash**: The Lodash implementation provides additional features and functions that may be useful in certain scenarios, but may also introduce overhead. * Pros: Provides a convenient way to use a pre-built, tested, and optimized implementation. * Cons: May have higher memory usage or introduce unnecessary complexity due to the added functionality. 3. **Lodash FP**: This variant uses functional programming principles, which can lead to more expressive code but may also incur additional overhead. * Pros: Can provide better readability and maintainability for some use cases. * Cons: May be slower than native or Lodash implementations, as it introduces additional function calls. **Library and Purpose** Lodash is a popular utility library that provides a set of helper functions to simplify common tasks in JavaScript. The `_.reduce()` function is part of this library and wraps the native JavaScript implementation. **Special JS Feature or Syntax** There is no explicit mention of any special JavaScript feature or syntax being used in the benchmark code. However, Lodash's functional programming variant uses a different approach to reduce functions, which may be unfamiliar to some developers. **Other Alternatives** If you were to rewrite this benchmark using alternative libraries or approaches, you might consider: 1. **Array.prototype.reduce() with a custom reducer function**: This would provide a similar performance profile to the native implementation but allow for more flexibility in terms of customization. 2. **A different utility library (e.g., Moment.js)**: Depending on the specific use case, another library like Moment.js might be a better fit than Lodash. Keep in mind that these alternatives would require significant changes to the benchmark code and may not provide the same level of comparison as the original implementation.
Related benchmarks:
Lodash reduce vs Lodash FP reduce
Lodash vs Lodash FP vs Native
Native vs Lodash vs Lodash FP - v3
Lodash vs Lodash/fp
Comments
Confirm delete:
Do you really want to delete benchmark?