paint-brush
[Performance] Lodash vs ES6 : map()by@peterchang_82818
18,731 reads
18,731 reads

[Performance] Lodash vs ES6 : map()

by May 13th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

As the result of the<a href="http://jsperf.com" target="_blank"> article in jsperf.com </a><em>(2015)</em>shows that, Lodash performances faster than Native Javascript. I was shocked! Lodash is built on top of Native Javascript, how come a wrapped lib could do the same things faster than its mother language?

Company Mentioned

Mention Thumbnail
featured image - [Performance] Lodash vs ES6 : map()
 HackerNoon profile picture

This experiment is designed to find out the performance and resource usage of map functions of both ES6 and Lodash

As the result of the article in jsperf.com _(2015)_shows that, Lodash performances faster than Native Javascript. I was shocked! Lodash is built on top of Native Javascript, how come a wrapped lib could do the same things faster than its mother language?

For the reason of curiosity, an experiment is made, by handling 10000 objects array, on both method, to see the different of between them by time, CPU and RAM.

Feel free to clone the git.

1- Generating a json file with 10,000 objects array

$ node gen

2- Two Fighting Players

es6 map vs lodash map speed

3- Kick off fighting

Result

As the table above shows, map() in ES6 performance more or less as same as Lodash, in term of CPU, Memory or Handling time.

Update

Thanks to correcting the experiment mistake, by Samuel Rouse and Zachary Leighton. Requiring Lodash module should have been considered.

Reference:

https://github.com/wahengchang/lodash-vs-es6

https://jsperf.com/native-map-vs-lodash-map

https://www.valentinog.com/blog/memory-usage-node-js/