Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.prototype.find vs Lodash find
(version: 0)
Comparing performance of:
Array.prototype.find vs Lodash find
Created:
7 years ago
by:
Guest
Go to the latest result
HTML Preparation code:
<script src="lodash.js"></script>
Script Preparation code:
var array = [...Array(100000).keys()];
Tests:
Array.prototype.find
array.find(n => n === 99999)
Lodash find
_.find(array,n => n === 99999)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.prototype.find
Lodash find
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Array.prototype.find
12K/s
Lodash find
1K/s
View exact numbers
Test name
Executions per second
✓
Array.prototype.find
11,699 Ops/sec
Lodash find
1,174 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **What is being tested?** The benchmark is comparing the performance of two approaches: 1. `Array.prototype.find` (native JavaScript method) 2. `_.find` (a method from the Lodash library) Both methods are supposed to find the first element in an array that satisfies a certain condition (in this case, `n === 99999`). **Options compared** The two options being compared are: * Native JavaScript: `Array.prototype.find` * Lodash: `_.find` **Pros and Cons of each approach** 1. **Native JavaScript (`Array.prototype.find`)** * Pros: + Built-in method, so it's likely to be highly optimized by the browser. + No additional library dependencies required. * Cons: + May have performance overhead due to the need for a function call and a loop to search for the element. 2. **Lodash (`_.find`)** * Pros: + Optimized for performance, as Lodash is designed to be fast and efficient. + Allows for more flexibility in terms of the search condition and the type of elements being searched (e.g., objects). * Cons: + Requires an additional library dependency (`lodash.js`), which may add overhead due to the need for loading and parsing the library. **Other considerations** The benchmark is using a fixed-size array of 100,000 elements, which provides a good test case for both methods. The search condition is simple (a single number comparison), which should help to isolate performance differences between the two approaches. **Lodash library** In this benchmark, Lodash is being used as a library to provide an alternative implementation of the `find` method. Lodash is a popular utility library that provides a range of functions for common tasks, such as array manipulation and data processing. In this case, the `_find` method is being used to search for the first element in the array that satisfies the condition. **Special JS feature or syntax** There are no special JavaScript features or syntaxes being tested in this benchmark. The code is straightforward and uses only standard JavaScript methods and syntax.
Related benchmarks
Array.prototype.some vs Lodash some
Array.includes vs Array.indexOf vs Lodash _.find
Comments
Confirm delete:
Do you really want to delete benchmark?