Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object array using find vs lodash find
(version: 0)
Comparing performance of:
object array find vs object array _.find
Created:
7 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.5/lodash.core.js"></script>
Tests:
object array find
var a = [{marble: "hihi0", text:'hello'}, {marble: "hihi1", text:'a'}, {marble: "hihi2", text:'bc'}]; var b = a.find(item => item.marble === 'hihi1');
object array _.find
var a = [{marble: "hihi0", text:'hello'}, {marble: "hihi1", text:'a'}, {marble: "hihi2", text:'bc'}]; var b = _.find(a, {marble: "hihi1"});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
object array find
object array _.find
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser/OS:
Chrome 134 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
object array find
18489498.0 Ops/sec
object array _.find
4466509.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what is tested, compared options, pros and cons, and other considerations. **Benchmark Overview** MeasureThat.net is a website where users can create and run JavaScript microbenchmarks to compare different approaches. The provided benchmark compares two ways of finding an object in an array: using the `find` method without any additional library (built-in JavaScript) versus using the `_` variable from the Lodash library. **Options Compared** Two options are compared: 1. **Built-in `find` method**: This is a standard JavaScript method that searches for an element with a given condition in an array. 2. **Lodash `_find` function**: Lodash is a popular JavaScript utility library that provides various functions, including `_find`, which performs the same operation as the built-in `find` method. **Pros and Cons** * **Built-in `find` method**: + Pros: Native JavaScript implementation, simple to use. + Cons: May not be optimized for performance or have additional features like Lodash. * **Lodash `_find` function**: + Pros: Can be faster than the built-in `find` method due to optimization, and provides additional functionality (e.g., support for promises). + Cons: Requires an external library, may add overhead due to HTTP request or bundle size. **Library Used** In this benchmark, Lodash is used. Specifically, it's version 4.17.5. The `_` variable from Lodash is used to invoke the `_find` function. The purpose of Lodash is to provide a set of reusable functions that make common programming tasks easier and more efficient. **Special JS Features or Syntax** There are no special JavaScript features or syntax mentioned in this benchmark. Both examples use standard JavaScript syntax for defining arrays, variables, and conditional statements. **Other Considerations** * **Performance overhead**: The Lodash library can introduce performance overhead due to HTTP requests or bundle size. However, in this specific benchmark, the Lodash `_find` function might be faster than the built-in `find` method. * **Feature parity**: If you don't use Lodash or similar libraries, you'll need to implement the `_find` functionality yourself, which can add development overhead and complexity. **Alternatives** If you don't want to use an external library like Lodash, you could: 1. Implement your own `_find` function using a standard JavaScript `for` loop or other methods. 2. Use another library that provides similar functionality, such as the `lodash-es` version (ES6+ compatible) or the `underscore` library. Keep in mind that alternatives might not offer the same level of optimization and performance as Lodash's `_find` function.
Related benchmarks:
Array.prototype.find vs Lodash find
Array.prototype.find vs Lodash find 2
Array find vs lodash _.find
native find vs lodash _.find equal
native find vs lodash _.find for objects equality
Comments
Confirm delete:
Do you really want to delete benchmark?