Home / Class/ HttpPostMultipartRequestDecoderBenchmark Class — netty Architecture

HttpPostMultipartRequestDecoderBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13["HttpPostMultipartRequestDecoderBenchmark"]
  8f5baaf1_593b_10b6_486b_673b93fff72f["HttpPostMultipartRequestDecoderBenchmark.java"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|defined in| 8f5baaf1_593b_10b6_486b_673b93fff72f
  5057a2d2_70c4_3974_f0da_62ea3d22078b["testHighNumberChunks()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| 5057a2d2_70c4_3974_f0da_62ea3d22078b
  a6b171c8_43ff_e9fc_f129_f7e27d8f85f7["multipartRequestDecoderHighDisabledLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| a6b171c8_43ff_e9fc_f129_f7e27d8f85f7
  7065ecd6_baad_0444_a079_b5eb8febb505["multipartRequestDecoderBigDisabledLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| 7065ecd6_baad_0444_a079_b5eb8febb505
  c198523f_b092_cfa3_ee90_803ee354acba["multipartRequestDecoderHighSimpleLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| c198523f_b092_cfa3_ee90_803ee354acba
  b29452a4_17e6_27ff_43db_1a74c09f0728["multipartRequestDecoderBigSimpleLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| b29452a4_17e6_27ff_43db_1a74c09f0728
  a7988f9b_fccc_9971_8086_9787ad6a3364["multipartRequestDecoderHighAdvancedLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| a7988f9b_fccc_9971_8086_9787ad6a3364
  0f424d18_28b8_b720_7e84_cccc88e4fc75["multipartRequestDecoderBigAdvancedLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| 0f424d18_28b8_b720_7e84_cccc88e4fc75
  a6aee0ea_edab_4998_9005_a35754057e56["multipartRequestDecoderHighParanoidLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| a6aee0ea_edab_4998_9005_a35754057e56
  4e7c0c51_39da_68dd_ea70_878549873e6e["multipartRequestDecoderBigParanoidLevel()"]
  7fc784ac_a898_377e_3ef7_6ba7dd38ad13 -->|method| 4e7c0c51_39da_68dd_ea70_878549873e6e

Relationship Graph

Source Code

microbench/src/main/java/io/netty/handler/codec/http/multipart/HttpPostMultipartRequestDecoderBenchmark.java lines 39–203

@Threads(1)
@Warmup(iterations = 2)
@Measurement(iterations = 3)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class HttpPostMultipartRequestDecoderBenchmark
        extends AbstractMicrobenchmark {

    public double testHighNumberChunks(boolean big, boolean noDisk) {
        String BOUNDARY = "01f136d9282f";
        int size = 8 * 1024;
        int chunkNumber = 64;
        StringBuilder stringBuilder = new StringBuilder(size);
        stringBuilder.setLength(size);
        String data = stringBuilder.toString();

        byte[] bodyStartBytes = ("--" + BOUNDARY + "\n" +
                                 "Content-Disposition: form-data; name=\"msg_id\"\n\n15200\n--" +
                                 BOUNDARY +
                                 "\nContent-Disposition: form-data; name=\"msg1\"; filename=\"file1.txt\"\n\n" +
                                 data).getBytes(CharsetUtil.UTF_8);
        byte[] bodyPartBigBytes = data.getBytes(CharsetUtil.UTF_8);
        byte[] intermediaryBytes = ("\n--" + BOUNDARY +
                                    "\nContent-Disposition: form-data; name=\"msg2\"; filename=\"file2.txt\"\n\n" +
                                    data).getBytes(CharsetUtil.UTF_8);
        byte[] finalBigBytes = ("\n" + "--" + BOUNDARY + "--\n").getBytes(CharsetUtil.UTF_8);
        ByteBuf firstBuf = Unpooled.wrappedBuffer(bodyStartBytes);
        ByteBuf finalBuf = Unpooled.wrappedBuffer(finalBigBytes);
        ByteBuf nextBuf;
        if (big) {
            nextBuf = Unpooled.wrappedBuffer(bodyPartBigBytes);
        } else {
            nextBuf = Unpooled.wrappedBuffer(intermediaryBytes);
        }
        DefaultHttpRequest req =
                new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.POST, "/up");
        req.headers().add(HttpHeaderNames.CONTENT_TYPE,
                          "multipart/form-data; boundary=" + BOUNDARY);

        long start = System.nanoTime();

        DefaultHttpDataFactory defaultHttpDataFactory =
                new DefaultHttpDataFactory(noDisk? 1024 * 1024 : 16 * 1024);
        HttpPostRequestDecoder decoder =
                new HttpPostRequestDecoder(defaultHttpDataFactory, req);
        firstBuf.retain();
        decoder.offer(new DefaultHttpContent(firstBuf));
        firstBuf.release();
        for (int i = 1; i < chunkNumber; i++) {
            nextBuf.retain();
            decoder.offer(new DefaultHttpContent(nextBuf));
            nextBuf.release();
            nextBuf.readerIndex(0);
        }
        finalBuf.retain();
        decoder.offer(new DefaultLastHttpContent(finalBuf));
        finalBuf.release();
        while (decoder.hasNext()) {
            InterfaceHttpData httpData = decoder.next();
        }
        while (finalBuf.refCnt() > 0) {
            finalBuf.release();
        }
        while (nextBuf.refCnt() > 0) {
            nextBuf.release();
        }
        while (finalBuf.refCnt() > 0) {
            finalBuf.release();
        }
        long stop = System.nanoTime();
        double time = (stop - start) / 1000000.0;
        defaultHttpDataFactory.cleanAllHttpData();
        defaultHttpDataFactory.cleanRequestHttpData(req);
        decoder.destroy();
        return time;
    }

    @Benchmark
    public double multipartRequestDecoderHighDisabledLevel() {
        final Level level = ResourceLeakDetector.getLevel();
        try {
            ResourceLeakDetector.setLevel(Level.DISABLED);

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free