Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
jsTest
(version: 0)
Comparing performance of:
native vs lodash
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
native
var array = [ { name: 'lim', age: 26 }, { name: 'kim', age: 28 }, { name: 'choi', age: 32 }, { name: 'park', age: 21 }, ] // native array.find(arr => arr.age < 28)
lodash
var array = [ { name: 'lim', age: 26 }, { name: 'kim', age: 28 }, { name: 'choi', age: 32 }, { name: 'park', age: 21 }, ] // lodash _.find(array, arr => arr.age < 28)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
native
lodash
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/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
native
44985972.0 Ops/sec
lodash
11697460.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON data and explain what's being tested. **Benchmark Definition** The benchmark definition represents a JavaScript function that is being executed multiple times to measure its performance. The code snippet in the "Benchmark Definition" field contains two examples: one using native JavaScript and the other using the Lodash library. * Native JavaScript example: ```javascript var array = [ { name: 'lim', age: 26 }, { name: 'kim', age: 28 }, { name: 'choi', age: 32 }, { name: 'park', age: 21 } ]; // native array.find(arr => arr.age < 28); ``` * Lodash library example: ```javascript var array = [ { name: 'lim', age: 26 }, { name: 'kim', age: 28 }, { name: 'choi', age: 32 }, { name: 'park', age: 21 } ]; // lodash _.find(array, arr => arr.age < 28); ``` **Options being compared** The two options being compared are: 1. **Native JavaScript**: The native JavaScript implementation uses the built-in `Array.prototype.find()` method. 2. **Lodash library**: The Lodash library provides a utility function called `_find()`, which is used to find the first element in an array that passes a test. **Pros and Cons** Here's a brief overview of the pros and cons of each approach: * **Native JavaScript (Array.prototype.find())** * Pros: + Native performance, as it leverages the browser's optimized implementation. + Easy to use and understand. * Cons: + Not available in older browsers that don't support ES6+ features. + May have slower performance compared to native implementations. * **Lodash library (_.find())** + Pros: + Widely supported across various browsers, including older ones. + Often used and well-maintained, ensuring consistent behavior. * Cons: + Adds an external dependency (Lodash) to the project. + May have slightly slower performance compared to native implementations. **Special JavaScript features or syntax** There are no special JavaScript features or syntax mentioned in this benchmark. The focus is on comparing the performance of native JavaScript versus using a third-party library like Lodash. If you'd like to explore other alternatives, consider the following: * **React Query**: A popular state management library that provides an optimized version of `Array.prototype.find()`. * **Underscore.js**: Another utility library that offers a `_find()` function similar to Lodash. * **Built-in performance optimizers**: Some browsers offer native performance optimizations for specific array methods, such as `Array.prototype.indexOf()` or `Array.prototype.includes()`.
Related benchmarks:
On2 vs Onlogn lengthOfLIS
Javascript array deducplication.
Javascript array deducplication 2.01
trsasdasd
Array.prototype.with() vs Array.prototype.toSpliced() 2
Comments
Confirm delete:
Do you really want to delete benchmark?