AsciiStringCaseConversionBenchmark Class — netty Architecture
Architecture documentation for the AsciiStringCaseConversionBenchmark class in AsciiStringCaseConversionBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1e87592d_0cd5_f888_674e_53d19ae3dd71["AsciiStringCaseConversionBenchmark"] bad701e2_a9b6_045d_a771_0a1f42291504["AsciiStringCaseConversionBenchmark.java"] 1e87592d_0cd5_f888_674e_53d19ae3dd71 -->|defined in| bad701e2_a9b6_045d_a771_0a1f42291504 3bae8980_85fb_61b4_ed2e_bd59a6e24a55["init()"] 1e87592d_0cd5_f888_674e_53d19ae3dd71 -->|method| 3bae8980_85fb_61b4_ed2e_bd59a6e24a55 2e3fce76_410d_aa84_609b_4f100eb30bd3["AsciiString()"] 1e87592d_0cd5_f888_674e_53d19ae3dd71 -->|method| 2e3fce76_410d_aa84_609b_4f100eb30bd3 97b32df4_7e90_ba3f_a1df_fd4398b1324f["String()"] 1e87592d_0cd5_f888_674e_53d19ae3dd71 -->|method| 97b32df4_7e90_ba3f_a1df_fd4398b1324f
Relationship Graph
Source Code
microbench/src/main/java/io/netty/util/AsciiStringCaseConversionBenchmark.java lines 33–120
@Threads(1)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Fork(2)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 8, time = 1)
@State(Scope.Benchmark)
public class AsciiStringCaseConversionBenchmark {
@Param({ "7", "16", "23", "32" })
int size;
@Param({ "4", "11" })
int logPermutations;
@Param({ "0" })
int seed;
int permutations;
AsciiString[] asciiStringData;
String[] stringData;
byte[] ret;
private int i;
@Param({ "true", "false" })
private boolean noUnsafe;
@Setup(Level.Trial)
public void init() {
System.setProperty("io.netty.noUnsafe", Boolean.valueOf(noUnsafe).toString());
final SplittableRandom random = new SplittableRandom(seed);
permutations = 1 << logPermutations;
ret = new byte[size];
asciiStringData = new AsciiString[permutations];
stringData = new String[permutations];
for (int i = 0; i < permutations; ++i) {
final int foundIndex = random.nextInt(Math.max(0, size - 8), size);
final byte[] byteArray = new byte[size];
int j = 0;
for (; j < size; j++) {
byte value = (byte) random.nextInt(0, (int) Byte.MAX_VALUE + 1);
// turn any found value into something different
if (j < foundIndex) {
if (AsciiStringUtil.isUpperCase(value)) {
value = AsciiStringUtil.toLowerCase(value);
}
}
if (j == foundIndex) {
value = 'N';
}
byteArray[j] = value;
}
asciiStringData[i] = new AsciiString(byteArray, false);
stringData[i] = asciiStringData[i].toString();
}
}
private AsciiString getData() {
return asciiStringData[i++ & permutations - 1];
}
private String getStringData() {
return stringData[i++ & permutations - 1];
}
@Benchmark
public AsciiString toLowerCase() {
return getData().toLowerCase();
}
@Benchmark
public AsciiString toUpperCase() {
return getData().toUpperCase();
}
@Benchmark
public String stringToLowerCase() {
return getStringData().toLowerCase();
}
Source
Frequently Asked Questions
What is the AsciiStringCaseConversionBenchmark class?
AsciiStringCaseConversionBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/util/AsciiStringCaseConversionBenchmark.java.
Where is AsciiStringCaseConversionBenchmark defined?
AsciiStringCaseConversionBenchmark is defined in microbench/src/main/java/io/netty/util/AsciiStringCaseConversionBenchmark.java at line 33.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free