Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map: Native vs Underscore vs Lodash
(version: 0)
Comparing performance of:
Native vs Underscore vs Lodash
Created:
5 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'></script>
Script Preparation code:
var randomArray = Array.apply(null, Array(100)).map(function() { return Math.round(Math.random() * 1000); }); // 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
var array2 = randomArray.map(function (value, index) { return value * 2 })
Underscore
var array2 = _underscore.map(randomArray, function (value, index) { return value * 2 })
Lodash
var array2 = _lodash.map(randomArray, function (value, index) { return value * 2 })
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 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
196131.3 Ops/sec
Underscore
398432.5 Ops/sec
Lodash
897237.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and its options. **What is being tested?** MeasureThat.net is testing three JavaScript libraries: Lodash, Underscore.js, and the native JavaScript implementation (without any additional libraries). Specifically, they are comparing the performance of these three implementations when performing a `map` operation on an array. **Options being compared** The options being compared are: 1. **Native JavaScript**: The built-in JavaScript `map` function, which is implemented in the JavaScript engine. 2. **Underscore.js**: A popular utility library that provides functional programming helpers, including the `map` function. 3. **Lodash**: Another popular utility library that provides a comprehensive set of functions, including the `map` function. **Pros and Cons** Here's a brief summary of the pros and cons of each option: 1. **Native JavaScript**: * Pros: Fastest execution time due to its native implementation. * Cons: May not be as flexible or powerful as other libraries. 2. **Underscore.js**: * Pros: Provides a more functional programming style, which can lead to more concise code. * Cons: May have slower execution times compared to native JavaScript. 3. **Lodash**: * Pros: Offers a wide range of utility functions, including `map`, which can be useful in many situations. * Cons: May have slower execution times compared to native JavaScript and Underscore.js. **Library descriptions** 1. **Underscore.js**: Developed by Jeremy Ashkenas, Underscore.js is a small and lightweight library that provides functional programming helpers for working with arrays, objects, and functions. The `map` function in Underscore.js applies a given function to each element of an array, returning a new array with the results. 2. **Lodash**: Developed by Isaac Schankman et al., Lodash is a comprehensive utility library that provides over 120 functions for working with arrays, objects, and more. The `map` function in Lodash applies a given function to each element of an array, returning a new array with the results. **Special JS features or syntax** None mentioned explicitly in the provided benchmark definitions. **Other alternatives** If you're looking for alternative JavaScript libraries that offer mapping functionality, some popular options include: 1. **Array.prototype.map()**: The built-in `map` function in modern JavaScript environments. 2. **Preact**: A lightweight library that provides a virtual DOM and a set of utility functions, including `map`. 3. **Ramda**: A functional programming library that provides a comprehensive set of utilities, including `map`. Keep in mind that the performance differences between these alternatives may vary depending on the specific use case and environment. **Benchmark preparation** The benchmark prepares an array with 100 random integers using `Array.apply(null, Array(100)).map()`. This is used as input for the three different implementations of the `map` function: native JavaScript, Underscore.js, and Lodash.
Related benchmarks:
Array.prototype.map vs Lodash.map
Array.prototype.map vs Lodash.map on large data
Lodash uniqBy vs Map destructuring
lodash vs map 4
_.merge vs _.assign vs JS reduce
Comments
Confirm delete:
Do you really want to delete benchmark?