HttpFragmentedRequestDecoderBenchmark Class — netty Architecture
Architecture documentation for the HttpFragmentedRequestDecoderBenchmark class in HttpFragmentedRequestDecoderBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ac596852_f546_4717_f225_2e73d54a1d6f["HttpFragmentedRequestDecoderBenchmark"] 1a53aee9_7742_c0ae_716f_c954fe3a3719["HttpFragmentedRequestDecoderBenchmark.java"] ac596852_f546_4717_f225_2e73d54a1d6f -->|defined in| 1a53aee9_7742_c0ae_716f_c954fe3a3719 78e383d1_ec0a_81bd_52af_86e8d6e21a98["stepsBuffers()"] ac596852_f546_4717_f225_2e73d54a1d6f -->|method| 78e383d1_ec0a_81bd_52af_86e8d6e21a98 71201cc8_be9c_a8b4_1dfd_a7b4768be458["initPipeline()"] ac596852_f546_4717_f225_2e73d54a1d6f -->|method| 71201cc8_be9c_a8b4_1dfd_a7b4768be458 a2b7a4e6_5da3_9106_4ce6_fa4de29794f5["releaseStepBuffers()"] ac596852_f546_4717_f225_2e73d54a1d6f -->|method| a2b7a4e6_5da3_9106_4ce6_fa4de29794f5 22fca9c2_2b9e_7822_953f_af29eb1b5190["testDecodeWholeRequestInMultipleStepsMixedDelimiters()"] ac596852_f546_4717_f225_2e73d54a1d6f -->|method| 22fca9c2_2b9e_7822_953f_af29eb1b5190
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/http/HttpFragmentedRequestDecoderBenchmark.java lines 51–126
@State(Scope.Benchmark)
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
public class HttpFragmentedRequestDecoderBenchmark extends AbstractMicrobenchmark {
@Param({ "64", "128" })
public int headerFragmentBytes;
@Param({ "false", "true" })
public boolean direct;
@Param({ "false", "true" })
public boolean pooled;
@Param({ "true", "false"})
public boolean validateHeaders;
private EmbeddedChannel channel;
private ByteBuf[] fragmentedRequest;
private static ByteBuf[] stepsBuffers(ByteBufAllocator alloc, byte[] content, int fragmentSize, boolean direct) {
// allocate a single big buffer and just slice it
final int headerLength = content.length - CONTENT_LENGTH;
final ArrayList<ByteBuf> bufs = new ArrayList<ByteBuf>();
for (int a = 0; a < headerLength;) {
int amount = fragmentSize;
if (a + amount > headerLength) {
amount = headerLength - a;
}
final ByteBuf buf = direct? alloc.directBuffer(amount, amount) : alloc.heapBuffer(amount, amount);
buf.writeBytes(content, a, amount);
bufs.add(buf);
a += amount;
}
// don't split the content
// Should produce HttpContent
final ByteBuf buf = direct?
alloc.directBuffer(CONTENT_LENGTH, CONTENT_LENGTH) :
alloc.heapBuffer(CONTENT_LENGTH, CONTENT_LENGTH);
buf.writeBytes(content, content.length - CONTENT_LENGTH, CONTENT_LENGTH);
bufs.add(buf);
return bufs.toArray(new ByteBuf[0]);
}
@Setup
public void initPipeline() {
final ByteBufAllocator allocator = pooled? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT;
fragmentedRequest = stepsBuffers(allocator, CONTENT_MIXED_DELIMITERS, headerFragmentBytes, direct);
channel = new EmbeddedChannel(
new HttpRequestDecoder(DEFAULT_MAX_INITIAL_LINE_LENGTH, DEFAULT_MAX_HEADER_SIZE, DEFAULT_MAX_CHUNK_SIZE,
validateHeaders, DEFAULT_INITIAL_BUFFER_SIZE));
}
@TearDown
public void releaseStepBuffers() {
for (ByteBuf buf : fragmentedRequest) {
buf.release();
}
}
@Benchmark
@CompilerControl(Mode.DONT_INLINE)
public void testDecodeWholeRequestInMultipleStepsMixedDelimiters() {
final EmbeddedChannel channel = this.channel;
for (ByteBuf buf : this.fragmentedRequest) {
buf.resetReaderIndex();
buf.retain();
channel.writeInbound(buf);
final Queue<Object> decoded = channel.inboundMessages();
Object o;
while ((o = decoded.poll()) != null) {
ReferenceCountUtil.release(o);
}
}
}
}
Defined In
Source
Frequently Asked Questions
What is the HttpFragmentedRequestDecoderBenchmark class?
HttpFragmentedRequestDecoderBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/http/HttpFragmentedRequestDecoderBenchmark.java.
Where is HttpFragmentedRequestDecoderBenchmark defined?
HttpFragmentedRequestDecoderBenchmark is defined in microbench/src/main/java/io/netty/microbench/http/HttpFragmentedRequestDecoderBenchmark.java at line 51.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free