Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Find: Native vs Underscore 1.13 vs Lodash 4.17
(version: 0)
updated versions
Comparing performance of:
Native vs Underscore vs Lodash
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js'></script> <script src='https://cdn.jsdelivr.net/npm/underscore@1.13.1/underscore-umd-min.js'></script>
Script Preparation code:
var users = [ { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 }, ] // Underscore was loaded last, so this saves an instance of underscore and resets _ to it's previous value (lodash). var _underscore = _.noConflict(); // This saves an instance of lodash and resets _ to it's previous value (undefined). var _lodash = _.noConflict();
Tests:
Native
users.find(function (o) { return o.age < 40; })
Underscore
_underscore.find(users, function (o) { return o.age < 40; })
Lodash
_lodash.find(users, function (o) { return o.age < 40; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native
Underscore
Lodash
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:148.0) Gecko/20100101 Firefox/148.0
Browser/OS:
Firefox 148 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native
1246092928.0 Ops/sec
Underscore
34161116.0 Ops/sec
Lodash
20117724.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks. **Benchmark Definition** The provided JSON represents a benchmark test that compares the performance of three different libraries: Native (built-in JavaScript), Underscore.js, and Lodash.js. The test case uses an array of objects (`users`) to simulate a common use case for finding elements in an array based on a condition. The condition is `o.age < 40`. **Options Compared** The options compared are: 1. Native (built-in JavaScript): This option tests the performance of the built-in JavaScript `find()` method. 2. Underscore.js: This option tests the performance of the Underscore.js library's `find()` method, which is a popular utility library for functional programming in JavaScript. 3. Lodash.js: This option tests the performance of the Lodash.js library's `find()` method, which builds upon Underscore.js and adds more functionality. **Pros and Cons** Here are some pros and cons of each approach: 1. Native (built-in JavaScript): * Pros: + Built-in, so no additional dependencies to worry about. + Can be optimized by the JavaScript engine. * Cons: + May not be as efficient as optimized third-party libraries. 2. Underscore.js: * Pros: + Well-maintained and widely adopted library. + Provides a consistent API for functional programming. * Cons: + Adds an extra dependency to the project. + May have performance overhead due to the library's functionality. 3. Lodash.js: * Pros: + Builds upon Underscore.js, so provides more features and optimization. + Still widely adopted and well-maintained. * Cons: + Adds two extra dependencies (Underscore.js and Lodash.js). + May have performance overhead due to the additional functionality. **Library Used** The test case uses: 1. Underscore.js: `_underscore.find(users, function (o) { return o.age < 40; })` * Purpose: Provides a consistent API for functional programming in JavaScript. 2. Lodash.js: `_lodash.find(users, function (o) { return o.age < 40; })` * Purpose: Builds upon Underscore.js and adds more functionality, including additional optimization. **Special JS Feature or Syntax** There is no special JS feature or syntax used in this benchmark test. **Other Alternatives** If you wanted to compare the performance of other libraries or built-in methods, here are some alternatives: 1. Other utility libraries: You could replace Underscore.js and Lodash.js with other popular utility libraries like Moment.js, jQuery, or even vanilla JavaScript's `filter()` method. 2. Built-in methods: You could use other built-in JavaScript methods like `Array.prototype.filter()`, `Array.prototype.map()`, or `Array.prototype.reduce()` to compare their performance. 3. Other frameworks or libraries: Depending on the specific use case, you might want to consider using other frameworks or libraries that provide similar functionality, such as React, Angular, or Vue.js. I hope this explanation helps!
Related benchmarks:
lodash find vs native find by id
Array find vs lodash _.find
native find vs lodash _.find equal
native find() vs lodash _.find() vs native some()
native find vs lodash _.find for objects equality
Comments
Confirm delete:
Do you really want to delete benchmark?