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
JDK 1.8.0_265, OpenJDK 64-Bit Server VM, 25.265-b01 | |
Benchmark Mode Cnt Score Error Units | |
StringBuilderChaining.chainingStringBuilder avgt 10 72.675 ± 1.548 ns/op | |
StringBuilderChaining.noChainingStringBuilder avgt 10 73.132 ± 2.126 ns/op | |
StringBuilderChaining.explicitConcat avgt 10 71.821 ± 1.274 ns/op | |
JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10 -XX:-OptimizeStringConcat | |
Benchmark Mode Cnt Score Error Units |
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
return leftFunction.concat("(") | |
.concat(alias).concat(".") | |
.concat(left).concat(")") | |
.concat(" ").concat(op).concat(" ") | |
.concat(":").concat(paramName); |
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
JDK 11.0.8, OpenJDK 64-Bit Server VM, 11.0.8+10 | |
Benchmark Mode Cnt Score Error Units | |
StringBuilderChainingFailure.noChaining avgt 10 56.246 ± 2.295 ns/op | |
StringBuilderChainingFailure.explicitConcat avgt 10 54.642 ± 0.696 ns/op | |
StringBuilderChainingFailure.explicitConcatImproved avgt 10 50.153 ± 0.597 ns/op |
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
@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; |
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
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 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
@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 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
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 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
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 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
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 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
@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) { |