https://github.com/amruthpillai/es6-vs-lodash
Here, I try to performance benchmark the speed complexity of the native ES6 `Array.map()` over the famous lodash library's `_.map(Array)` function. The results were quite surprising to say the least.
https://github.com/amruthpillai/es6-vs-lodash
Last synced: 6 months ago
JSON representation
Here, I try to performance benchmark the speed complexity of the native ES6 `Array.map()` over the famous lodash library's `_.map(Array)` function. The results were quite surprising to say the least.
- Host: GitHub
- URL: https://github.com/amruthpillai/es6-vs-lodash
- Owner: AmruthPillai
- Created: 2019-02-25T20:59:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-25T21:09:32.000Z (over 6 years ago)
- Last Synced: 2024-05-02T05:37:14.747Z (over 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `[].map()` vs `_.map()`
Here, I try to performance benchmark the speed complexity of the native ES6 `Array.map()` over the famous lodash library's `_.map(Array)` function. The results were quite surprising to say the least.
## Running the Test
```console
$ node test
```## Reading the Output
Mapping over an Array of **1,000 objects**:
```
ES6 Lodash
Time Elapsed 0.037 ms 0.040 ms
```Mapping over an Array of **10,000 objects**:
```
ES6 Lodash
Time Elapsed 0.159 ms 0.159 ms
```Mapping over an Array of **100,000 objects**:
```
ES6 Lodash
Time Elapsed 11.870 ms 1.701 ms
```Mapping over an Array of **1,000,000 objects**:
```
ES6 Lodash
Time Elapsed 120.790 ms 16.513 ms
```## Conclusion
We don't tend to see much of a difference with really small arrays (< 10,000 objects), but when it really gets large, which is a rare case on the frontend, lodash seems to be performing better than ES6's own native `.map` function.
If you feel like I have performed the test incorrectly, or you have any other metrics which can be shared, then please fork this repo, make your suggested changes and make a pull request.