This file contains 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class ReplaceAll { | |
@Param({"", "somePathNoDoT", "some.Path.With.Dot"}) | |
String value; |
This file contains 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
JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10 | |
Benchmark (strParams) Mode Cnt Score Error Units | |
EnumValueOf.enumMap LABEL avgt 10 11.749 ± 0.761 ns/op | |
EnumValueOf.enumMap ON_LABEL avgt 10 11.778 ± 0.306 ns/op | |
EnumValueOf.enumMap MAX avgt 10 10.517 ± 0.056 ns/op | |
EnumValueOf.enumSwitch LABEL avgt 80 7.149 ± 0.030 ns/op | |
EnumValueOf.enumSwitch ON_LABEL avgt 80 7.758 ± 0.077 ns/op | |
EnumValueOf.enumSwitch MAX avgt 80 6.948 ± 0.083 ns/op | |
EnumValueOf.enumValueOf LABEL avgt 80 15.659 ± 0.450 ns/op |
This file contains 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
JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10 | |
Benchmark Mode Cnt Score Error Units | |
EnumValues.enumValuesMethod avgt 10 21.576 ± 0.225 ns/op | |
EnumValues.enumValuesVariable avgt 10 16.811 ± 0.095 ns/op |
This file contains 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class EnumValues { | |
@Benchmark | |
public void enumValuesMethod(Blackhole bh) { |
This file contains 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
Map<String, T> enumConstantDirectory() { | |
Map<String, T> directory = enumConstantDirectory; | |
if (directory == null) { | |
T[] universe = getEnumConstantsShared(); | |
if (universe == null) | |
throw new IllegalArgumentException( | |
getName() + " is not an enum type"); | |
directory = new HashMap<>((int)(universe.length / 0.75f) + 1); | |
for (T constant : universe) { | |
directory.put(((Enum<?>)constant).name(), constant); |
This file contains 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
public static <T extends Enum<T>> T valueOf(Class<T> enumType, | |
String name) { | |
T result = enumType.enumConstantDirectory().get(name); | |
if (result != null) | |
return result; | |
if (name == null) | |
throw new NullPointerException("Name is null"); | |
throw new IllegalArgumentException( | |
"No enum constant " + enumType.getCanonicalName() + "." + name); | |
} |
This file contains 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
JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10 | |
Benchmark (strParams) Mode Cnt Score Error Units | |
EnumValueOf.enumSwitch LABEL avgt 80 7.149 ± 0.030 ns/op | |
EnumValueOf.enumSwitch ON_LABEL avgt 80 7.758 ± 0.077 ns/op | |
EnumValueOf.enumSwitch MAX avgt 80 6.948 ± 0.083 ns/op | |
EnumValueOf.enumValueOf LABEL avgt 80 15.659 ± 0.450 ns/op | |
EnumValueOf.enumValueOf ON_LABEL avgt 80 14.734 ± 0.542 ns/op | |
EnumValueOf.enumValueOf MAX avgt 80 15.153 ± 0.578 ns/op |
This file contains 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class EnumValueOf { | |
@Param({"LABEL", "ON_LABEL", "MAX"}) | |
String strParams; |
This file contains 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
public static WidgetProperty valueOfSwitch(String value) { | |
switch (value) { | |
case "LABEL" : | |
return WidgetProperty.LABEL; | |
case "COLOR" : | |
return WidgetProperty.COLOR; | |
case "ON_LABEL" : | |
return WidgetProperty.ON_LABEL; | |
case "OFF_LABEL" : | |
return WidgetProperty.OFF_LABEL; |
This file contains 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(value = 1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class StringBuilderChainingFailure { | |
String[] sqlColumnNames; |