DEV Community

loading...

Loops vs HashSets

jtenos profile image Joe Enos ・1 min read

You know that it's faster to find a value in a HashSet rather than a regular collection. But how much faster?

Turns out that looping through a lot of values is pretty slow, while looking up in that same collection as a HashSet is practically instant - tens of thousands of times faster in the example I show here:

Discussion (0)

Forem Open with the Forem app