ES6 Set Performance in Chrome's V8 JavaScript Engine

One of the nice things that came with ES6 were native Sets, provided so that developers didn’t have to keep importing or rolling their own custom Set polyfills. As I was writing a post about the advantages of using an EnumSet over a generic Set, I coded up and included some performance examples which yielded some very surprising results.

It turns out that the Set implementation in Chrome’s V8 JavaScript Engine is very slow, about 2x slower than a Naive Set polyfill using a Map<String, Boolean>.

I have included the test below using the following Set implementations, compared to the native ES6 Set implementation.