HttpRequestEncoderBenchmark Class — netty Architecture
Architecture documentation for the HttpRequestEncoderBenchmark class in HttpRequestEncoderBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 8879ea80_f499_de37_89e2_c6faf236521a["HttpRequestEncoderBenchmark"] c9e0b178_011a_6e98_2c33_2c434f9eb873["HttpRequestEncoderBenchmark.java"] 8879ea80_f499_de37_89e2_c6faf236521a -->|defined in| c9e0b178_011a_6e98_2c33_2c434f9eb873 6fe9d6dc_40e8_db94_6ffa_4037c27133b5["setup()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 6fe9d6dc_40e8_db94_6ffa_4037c27133b5 43808321_4de2_730f_b570_85a1017432f0["teardown()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 43808321_4de2_730f_b570_85a1017432f0 4022dc89_afaa_0e9f_bc1e_97bb7196be8b["fullMessage()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 4022dc89_afaa_0e9f_bc1e_97bb7196be8b 16a897d3_6e04_0433_0069_525b3bb8b06a["contentLength()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 16a897d3_6e04_0433_0069_525b3bb8b06a 0f7e97a1_96d2_e1b5_65d4_e62a3f471475["chunked()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 0f7e97a1_96d2_e1b5_65d4_e62a3f471475 92606a59_73fb_4bab_78bb_ebea94d7f655["differentTypes()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 92606a59_73fb_4bab_78bb_ebea94d7f655 81ede4b2_aa9c_0a69_0277_82f34747a032["ChannelPromise()"] 8879ea80_f499_de37_89e2_c6faf236521a -->|method| 81ede4b2_aa9c_0a69_0277_82f34747a032
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/http/HttpRequestEncoderBenchmark.java lines 51–152
@State(Scope.Thread)
@Fork(2)
@Warmup(iterations = 5)
@Measurement(iterations = 10)
public class HttpRequestEncoderBenchmark extends AbstractMicrobenchmark {
private HttpRequestEncoder encoder;
private FullHttpRequest fullRequest;
private LastHttpContent lastContent;
private HttpRequest contentLengthRequest;
private HttpRequest chunkedRequest;
private ByteBuf content;
private ChannelHandlerContext context;
@Param({ "true", "false" })
public boolean pooledAllocator;
@Param({ "true", "false" })
public boolean voidPromise;
@Param({ "false", "true" })
public boolean typePollution;
@Param({ "128" })
private int contentBytes;
@Setup(Level.Trial)
public void setup() throws Exception {
byte[] bytes = new byte[contentBytes];
content = Unpooled.buffer(bytes.length);
content.writeBytes(bytes);
ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());
DefaultHttpHeadersFactory headersFactory = DefaultHttpHeadersFactory.headersFactory().withValidation(false);
HttpHeaders headersWithChunked = headersFactory.newHeaders();
headersWithChunked.add(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
HttpHeaders headersWithContentLength = headersFactory.newHeaders();
headersWithContentLength.add(HttpHeaderNames.CONTENT_LENGTH, testContent.readableBytes());
fullRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/index", testContent,
headersWithContentLength, EmptyHttpHeaders.INSTANCE);
contentLengthRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/index",
headersWithContentLength);
chunkedRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/index", headersWithChunked);
lastContent = new DefaultLastHttpContent(testContent, headersFactory);
encoder = new HttpRequestEncoder();
context = new EmbeddedChannelWriteReleaseHandlerContext(pooledAllocator ? PooledByteBufAllocator.DEFAULT :
UnpooledByteBufAllocator.DEFAULT, encoder) {
@Override
protected void handleException(Throwable t) {
handleUnexpectedException(t);
}
};
if (typePollution) {
for (int i = 0; i < 20000; i++) {
differentTypes();
}
}
}
@TearDown(Level.Trial)
public void teardown() {
content.release();
content = null;
}
@Benchmark
public void fullMessage() throws Exception {
fullRequest.content().setIndex(0, contentBytes);
encoder.write(context, fullRequest, newPromise());
}
@Benchmark
public void contentLength() throws Exception {
encoder.write(context, contentLengthRequest, newPromise());
lastContent.content().setIndex(0, contentBytes);
encoder.write(context, lastContent, newPromise());
}
@Benchmark
public void chunked() throws Exception {
encoder.write(context, chunkedRequest, newPromise());
Source
Frequently Asked Questions
What is the HttpRequestEncoderBenchmark class?
HttpRequestEncoderBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/http/HttpRequestEncoderBenchmark.java.
Where is HttpRequestEncoderBenchmark defined?
HttpRequestEncoderBenchmark is defined in microbench/src/main/java/io/netty/microbench/http/HttpRequestEncoderBenchmark.java at line 51.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free