-
-
Save soberich/6d9456338ade48bfa36953519cf5e6eb to your computer and use it in GitHub Desktop.
EnumSet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sergej@sergej-P50:~/Development/IdeaProjects/playground$ /home/sergej/.sdkman/candidates/java/13.0.1.hs-adpt/bin/java -version | |
openjdk version "13.0.1" 2019-10-15 | |
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.1+9) | |
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.1+9, mixed mode, sharing) | |
sergej@sergej-P50:~/Development/IdeaProjects/playground$ uname -a | |
Linux sergej-P50 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux | |
jol >> java.util.RegularEnumSet, size=1584 | |
jol >> org.eclipse.collections.impl.set.mutable.UnifiedSet, size=976 | |
jol >> org.eclipse.collections.impl.set.immutable.ImmutableUnifiedSet, size=992 | |
@Test | |
void set() { | |
EnumSet<V> jdkEnumSet = EnumSet.allOf(V.class); | |
measureJol(jdkEnumSet); | |
MutableSet<V> ecMutableSet = Sets.mutable.of(V.values()); | |
measureJol(ecMutableSet); | |
ImmutableSet<V> immutableSet = Sets.immutable.of(V.values()); | |
measureJol(immutableSet); | |
} | |
enum V { | |
MY_VALUE_1, | |
MY_VALUE_2, | |
MY_VALUE_3, | |
MY_VALUE_4, | |
MY_VALUE_5, | |
MY_VALUE_6, | |
MY_VALUE_7, | |
MY_VALUE_8, | |
MY_VALUE_9, | |
MY_VALUE_10, | |
} | |
private static void measureJol(Object o) { | |
long memory = GraphLayout.parseInstance(o).totalSize(); | |
System.out.printf("jol >> %s, size=%d%n", o.getClass().getCanonicalName(), memory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment