HttpRequestEncoderInsertBenchmark Class — netty Architecture
Architecture documentation for the HttpRequestEncoderInsertBenchmark class in HttpRequestEncoderInsertBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ff555f9c_1d77_6f5a_cb29_37e270340371["HttpRequestEncoderInsertBenchmark"] 651511e0_d60d_a4e2_af23_af490ffcdf41["HttpRequestEncoderInsertBenchmark.java"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|defined in| 651511e0_d60d_a4e2_af23_af490ffcdf41 cdc875a8_e50a_f313_7cc3_77a860eb76b8["setup()"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|method| cdc875a8_e50a_f313_7cc3_77a860eb76b8 e81c8d5f_3d2a_9f6e_3727_a618363d278c["permute()"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|method| e81c8d5f_3d2a_9f6e_3727_a618363d278c f092d363_d366_7931_7abd_8b7b99baf79f["swap()"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|method| f092d363_d366_7931_7abd_8b7b99baf79f 449b801c_af8f_4b78_6506_b804b5e4a38f["String()"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|method| 449b801c_af8f_4b78_6506_b804b5e4a38f a422f1ab_5356_fda9_202c_ed213f3d5ca3["ByteBuf()"] ff555f9c_1d77_6f5a_cb29_37e270340371 -->|method| a422f1ab_5356_fda9_202c_ed213f3d5ca3
Relationship Graph
Source Code
microbench/src/main/java/io/netty/handler/codec/http/HttpRequestEncoderInsertBenchmark.java lines 41–189
@State(Scope.Benchmark)
@Warmup(iterations = 10)
@Measurement(iterations = 20)
public class HttpRequestEncoderInsertBenchmark extends AbstractMicrobenchmark {
private static final String[] PARAMS = {
"eventType=CRITICAL",
"from=0",
"to=1497437160327",
"limit=10",
"offset=0"
};
@Param({"1024", "128000"})
private int samples;
private String[] uris;
private int index;
private final OldHttpRequestEncoder encoderOld = new OldHttpRequestEncoder();
private final HttpRequestEncoder encoderNew = new HttpRequestEncoder();
@Setup
public void setup() {
List<String[]> permutations = new ArrayList<>();
permute(PARAMS.clone(), 0, permutations);
String[] allCombinations = new String[permutations.size()];
String base = "http://localhost?";
for (int i = 0; i < permutations.size(); i++) {
StringBuilder sb = new StringBuilder(base);
String[] p = permutations.get(i);
for (int j = 0; j < p.length; j++) {
if (j != 0) {
sb.append('&');
}
sb.append(p[j]);
}
allCombinations[i] = sb.toString();
}
uris = new String[samples];
SplittableRandom rand = new SplittableRandom(42);
for (int i = 0; i < uris.length; i++) {
uris[i] = allCombinations[rand.nextInt(allCombinations.length)];
}
index = 0;
}
private static void permute(String[] arr, int start, List<String[]> out) {
if (start == arr.length - 1) {
out.add(Arrays.copyOf(arr, arr.length));
return;
}
for (int i = start; i < arr.length; i++) {
swap(arr, start, i);
permute(arr, start + 1, out);
swap(arr, start, i);
}
}
private static void swap(String[] a, int i, int j) {
String t = a[i];
a[i] = a[j];
a[j] = t;
}
private String nextUri() {
if (index >= uris.length) {
index = 0;
}
return uris[index++];
}
@Benchmark
public ByteBuf oldEncoder() throws Exception {
ByteBuf buffer = Unpooled.buffer(100);
try {
encoderOld.encodeInitialLine(buffer, new DefaultHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.GET, nextUri()));
return buffer;
} finally {
buffer.release();
}
Defined In
Source
Frequently Asked Questions
What is the HttpRequestEncoderInsertBenchmark class?
HttpRequestEncoderInsertBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http/HttpRequestEncoderInsertBenchmark.java.
Where is HttpRequestEncoderInsertBenchmark defined?
HttpRequestEncoderInsertBenchmark is defined in microbench/src/main/java/io/netty/handler/codec/http/HttpRequestEncoderInsertBenchmark.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free