Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash map vs es6 Object.values.map
(version: 0)
Comparing performance of:
lodash map vs native map
Created:
4 years ago
by:
Guest
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 Preparation code:
const j = { '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12, '13': 13 } function lodashmap () { arr = _.map(j, function(el){ return el + 10 }) console.log(arr) } function jsmap () { arr = Object.values(j).map((el) => el + 10) }
Tests:
lodash map
lodashmap()
native map
jsmap()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash map
native map
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what is being tested. **What is being tested?** The provided JSON represents two JavaScript microbenchmarks: 1. `lodashmap()`: This function uses the Lodash library to create a new array by mapping over the values of an object (`j`). The mapping function adds 10 to each value. 2. `jsmap()`: This function uses the native JavaScript `map()` method to achieve the same result as above, but without relying on any external libraries. **Options being compared** The benchmark is comparing two approaches: * **Lodash map**: Using the Lodash library (`_`) to create a new array by mapping over the values of an object. * **Native map**: Using the native JavaScript `map()` method to achieve the same result without relying on any external libraries. **Pros and cons of each approach** **Lodash map:** Pros: * Easier to read and write, especially for developers familiar with Lodash. * Provides a more robust set of utility functions that can be used in conjunction with mapping. Cons: * Requires an additional library download and setup. * May have performance overhead due to the need to load the library. **Native map:** Pros: * Faster execution time since it doesn't require loading an external library. * More lightweight and efficient since it only uses built-in JavaScript functions. Cons: * May require more code to achieve the same result, which can make it less readable for some developers. * Limited to only using built-in JavaScript features. **Other considerations** * The benchmark is running on a Chrome 98 browser on a Mac OS X 10.15.7 system, which may affect the results due to various factors such as system resources and hardware configurations. * The `ExecutionsPerSecond` metric provides an idea of the performance difference between the two approaches. **Library description** The Lodash library is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, string formatting, and more. In this benchmark, it's being used to simplify the mapping process over the `j` object. **Special JS feature or syntax** None mentioned in the provided information. However, using the `map()` method is a JavaScript feature that allows developers to create new arrays by transforming existing elements. **Alternative benchmarks** To test alternative approaches, additional benchmark cases could be added, such as: * Using other libraries like Array.prototype.map() ( native array methods) * Implementing a custom mapping function from scratch * Using different programming paradigms or functional programming styles These additional benchmark cases would help to provide a more comprehensive understanding of the performance differences between various JavaScript approaches.
Related benchmarks:
Array.prototype.map vs Lodash.map
lodash map vs es6 map v2
Array.prototype.map vs Lodash.map 4.17.15
array.map vs _.map
Comments
Confirm delete:
Do you really want to delete benchmark?