A 10× Faster Hash Table for Node.js
github.com
github.com
Also, while a Set can technically receive an Array (or iterable) upfront in the constructor, this requires you to have your Array available upfront, which is not always the case, and an Array is also not meant for millions of objects in the first place. For example, AFAIK (and I may be wrong since last I checked) but V8's Array will switch mode and degrade into an object at around 10,000 elements.
So with Set (or Map) there's still no production-quality way to allocate and reserve capacity upfront by the number of elements or size in bytes.
Please note, the `vanilla.js` comparison in the Motivation section is not meant as a benchmark, but just to sketch the principles outlined there.
You don't actually even see the 10× differential with `vanilla.js` because it only inserts 4,000,000 elements - I would have set it higher but Set and Object start taking forever or cause OOM crashes beyond that.
More accurate, in-depth performance numbers are here: https://github.com/ronomon/hash-table#performance