Home / Class/ HttpPostDecoderBenchmark Class — netty Architecture

HttpPostDecoderBenchmark Class — netty Architecture

Architecture documentation for the HttpPostDecoderBenchmark class in HttpPostDecoderBenchmark.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  90cad539_5ee5_ce23_b02d_1cbef3a4190d["HttpPostDecoderBenchmark"]
  d6120638_9b40_17a7_9db7_32f7ca42aafc["HttpPostDecoderBenchmark.java"]
  90cad539_5ee5_ce23_b02d_1cbef3a4190d -->|defined in| d6120638_9b40_17a7_9db7_32f7ca42aafc
  bab8206c_6766_2b23_3f64_8879716f141c["setUp()"]
  90cad539_5ee5_ce23_b02d_1cbef3a4190d -->|method| bab8206c_6766_2b23_3f64_8879716f141c
  991aa134_ff36_15ab_0159_6cf71cfbc9c6["CharSequence()"]
  90cad539_5ee5_ce23_b02d_1cbef3a4190d -->|method| 991aa134_ff36_15ab_0159_6cf71cfbc9c6
  c7e297c9_08b1_9071_4555_c2d876f10c1e["decode()"]
  90cad539_5ee5_ce23_b02d_1cbef3a4190d -->|method| c7e297c9_08b1_9071_4555_c2d876f10c1e

Relationship Graph

Source Code

microbench/src/main/java/io/netty/handler/codec/http/HttpPostDecoderBenchmark.java lines 39–85

@Threads(1)
@Warmup(iterations = 3)
@Measurement(iterations = 3)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class HttpPostDecoderBenchmark extends AbstractMicrobenchmark {
    @Param({ "false", "true" })
    public boolean direct;

    private ByteBuf buf;
    private HttpRequest request;

    @Setup()
    public void setUp() {
        request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/post");
        request.headers().add(HttpHeaderNames.CONTENT_TYPE, "application/x-www-form-urlencoded");
        buf = direct ? Unpooled.directBuffer() : Unpooled.buffer();
        for (int i = 0; i < 100; i++) {
            if (i != 0) {
                buf.writeByte('&');
            }
            ByteBufUtil.writeAscii(buf, "form-field-" + i);
            buf.writeByte('=');

            ByteBufUtil.writeAscii(buf, randomString());
        }
    }

    private static CharSequence randomString() {
        Random rng = ThreadLocalRandom.current();
        int len = 4 + rng.nextInt(110);
        StringBuilder sb = new StringBuilder(len);
        for (int i = 0; i < len; i++) {
            String chars = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ";
            sb.append(chars.charAt(rng.nextInt(chars.length())));
        }
        return sb;
    }

    @Benchmark
    public List<InterfaceHttpData> decode() {
        HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(request);
        DefaultLastHttpContent content = new DefaultLastHttpContent(buf.duplicate());
        decoder.offer(content);
        return decoder.getBodyHttpDatas();
    }
}

Frequently Asked Questions

What is the HttpPostDecoderBenchmark class?
HttpPostDecoderBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http/HttpPostDecoderBenchmark.java.
Where is HttpPostDecoderBenchmark defined?
HttpPostDecoderBenchmark is defined in microbench/src/main/java/io/netty/handler/codec/http/HttpPostDecoderBenchmark.java at line 39.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free