Hacker News new | past | comments | ask | show | jobs | submit login
The Cost of Java's EnumSet (nullprogram.com)
2 points by ingve on April 23, 2021 | hide | past | favorite | 1 comment



One 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: