Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash find vs native find
(version: 0)
Comparing performance of:
array find vs lodash find
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
Script Preparation code:
var users = [{ 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, ]
Tests:
array find
users.find(function (o) { return o.age < 40; })
lodash find
_.find(users, function (o) { return o.age < 40; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array find
lodash find
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):
I'll break down the benchmark and its components, explaining what's being tested, compared, and their pros and cons. **Benchmark Definition JSON** The benchmark is designed to compare the performance of native JavaScript array methods (`find`) with the popular utility library `lodash`'s implementation of the same method (`_.find`). **Script Preparation Code** This code snippet prepares an array of objects: ```javascript var users = [ { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, // ... ] ``` The `users` array contains multiple identical objects with different values for the `'user'` and `'age'` properties. This is done to simulate a large dataset. **Html Preparation Code** This code snippet includes the `lodash.js` library, which will be used in the benchmark: ```html <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script> ``` **Individual Test Cases** There are two test cases: 1. **Native `find` method**: This test case uses the native JavaScript array method `find`, which takes a callback function as an argument. ```javascript users.find(function (o) { return o.age < 40; }) ``` This implementation finds the first object in the `users` array where the `'age'` property is less than 40. 2. **Lodash `_find` method**: This test case uses the `lodash` library's implementation of the `_find` method. ```javascript _.find(users, function (o) { return o.age < 40; }) ``` This implementation also finds the first object in the `users` array where the `'age'` property is less than 40. **Latest Benchmark Result** The benchmark result shows the performance of both test cases: 1. **Native `find` method**: The native JavaScript array method executes at a rate of approximately 825,397,680 executions per second. 2. **Lodash `_find` method**: The `lodash` library's implementation executes at a significantly slower rate of approximately 11,411,021 executions per second. **Comparison and Pros/Cons** The benchmark compares the performance of native JavaScript array methods with the popular utility library `lodash`'s implementation. Pros of using native JavaScript array methods: * Faster execution rates * Less overhead due to the use of a third-party library Cons of using native JavaScript array methods: * Limited functionality compared to utility libraries like `lodash` * May not be compatible with older browsers or environments that don't support modern JavaScript features Pros of using a utility library like `lodash`: * Provides additional functionality and convenience * Often includes more robust and efficient implementations than native methods Cons of using a utility library like `lodash`: * Slower execution rates compared to native methods * Adds overhead due to the use of an external library. In this specific benchmark, the native JavaScript array method outperforms the `lodash` implementation. However, in other scenarios, a utility library like `lodash` might be a better choice due to its additional functionality and convenience.
Related benchmarks:
native reverse find vs lodash _.findLast larger sample
native find vs lodash _.find with null values and object
native find vs lodash _.find altered
native find vs lodash _.find for objects equality
Comments
Confirm delete:
Do you really want to delete benchmark?