2 ms·
The Cost of Java's EnumSet
- kaba0 6y agoOne should use JMH to microbenchmark Java. And frankly, the benchmark doesn’t really make sense. EnumSets are predominantly used for passing some sort of config flags in C-style. So it gets created only a few times, unlikely to ever be a hotspot. So counting the memory requirement would have been wiser, but it is trivially one object and an object-reference vs an int. If you have many many objects with such a field, then it may make sense to go back to ints, but yet again, used predominantly as a config “format”, that one singleton Java class will not be better off either way.