DecodeHexBenchmark Class — netty Architecture
Architecture documentation for the DecodeHexBenchmark class in DecodeHexBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf["DecodeHexBenchmark"] 14aa2c58_8f80_4415_2c53_7d81ece47eaf["DecodeHexBenchmark.java"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|defined in| 14aa2c58_8f80_4415_2c53_7d81ece47eaf 7041c9e4_9b26_8966_9efc_ee216f8a3ea4["init()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 7041c9e4_9b26_8966_9efc_ee216f8a3ea4 28c82bad_6821_e9c2_04cf_3a2b062c9264["shuffle()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 28c82bad_6821_e9c2_04cf_3a2b062c9264 dedc7f04_282f_b427_184d_ab9ed5b7d5c2["nextHexDigits()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| dedc7f04_282f_b427_184d_ab9ed5b7d5c2 ddcbd000_b7c4_9660_6917_1dad06c10102["hexDigits()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| ddcbd000_b7c4_9660_6917_1dad06c10102 64eb5327_92dd_9981_06c2_9c28a14a7461["hexDigitsWithChecks()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 64eb5327_92dd_9981_06c2_9c28a14a7461 15e66ba0_6c18_6eb9_a9f3_30226cb093a1["hexDigitsOriginal()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 15e66ba0_6c18_6eb9_a9f3_30226cb093a1 6d519e34_548d_1ed1_0ebf_25a878b038c9["decodeHexNibble()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 6d519e34_548d_1ed1_0ebf_25a878b038c9 2d1d5aef_40fb_0323_14be_4d9799b66e4d["decodeHexNibbleWithCheck()"] 5c3828dc_c4a2_3a97_8b53_37a9c4e8cecf -->|method| 2d1d5aef_40fb_0323_14be_4d9799b66e4d
Relationship Graph
Source Code
microbench/src/main/java/io/netty/handler/codec/http/DecodeHexBenchmark.java lines 37–177
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class DecodeHexBenchmark extends AbstractMicrobenchmark {
@Param({
//with HEX chars
"135aBa9BBCEA030b947d79fCcaf48Bde",
//with HEX chars + 'g'
"4DDeA5gDD1C6fE567E1b6gf0C40FEcDg",
})
private String hex;
// Needs to specify a high number of inputs to allow the current strategy
// on nextHexDigits to produce enough branch-misses
@Param({ "2048" })
private int inputs;
private char[][] hexDigits;
private static final long SEED = 1578675524L;
private long next;
@Setup
public void init() {
final char[] hexCh = hex.toCharArray();
next = 0;
inputs = MathUtil.findNextPositivePowerOfTwo(inputs);
hexDigits = new char[inputs][];
hexDigits[0] = hexCh;
if (inputs > 1) {
final Random rnd = new Random(SEED);
for (int i = 1; i < inputs; i++) {
hexDigits[i] = shuffle(Arrays.copyOf(hexCh, hexCh.length), rnd);
}
}
}
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
private static char[] shuffle(char[] chars, Random rnd) {
int index;
char tmp;
for (int i = chars.length - 1; i > 0; i--) {
index = rnd.nextInt(i + 1);
tmp = chars[index];
chars[index] = chars[i];
chars[i] = tmp;
}
return chars;
}
private int nextHexDigits() {
final int idx = (int) (next & (inputs - 1));
next++;
return idx;
}
@Benchmark
@CompilerControl(Mode.DONT_INLINE)
public long hexDigits() {
long v = 0;
final char[] hexDigits = this.hexDigits[nextHexDigits()];
for (int i = 0, size = hexDigits.length; i < size; i++) {
v += StringUtil.decodeHexNibble(hexDigits[i]);
}
return v;
}
@Benchmark
@CompilerControl(Mode.DONT_INLINE)
public long hexDigitsWithChecks() {
long v = 0;
final char[] hexDigits = this.hexDigits[nextHexDigits()];
for (int i = 0, size = hexDigits.length; i < size; i++) {
v += decodeHexNibbleWithCheck(hexDigits[i]);
}
return v;
}
@Benchmark
@CompilerControl(Mode.DONT_INLINE)
public long hexDigitsOriginal() {
long v = 0;
Source
Frequently Asked Questions
What is the DecodeHexBenchmark class?
DecodeHexBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http/DecodeHexBenchmark.java.
Where is DecodeHexBenchmark defined?
DecodeHexBenchmark is defined in microbench/src/main/java/io/netty/handler/codec/http/DecodeHexBenchmark.java at line 37.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free