Home / Class/ StompEncoderBenchmark Class — netty Architecture

StompEncoderBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  86cc379c_ed38_013b_cfa3_8c8e137ac012["StompEncoderBenchmark"]
  82394193_cfbc_c7c3_686f_0fff2550c932["StompEncoderBenchmark.java"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|defined in| 82394193_cfbc_c7c3_686f_0fff2550c932
  714f5115_9e41_3fac_298a_669ac690c883["setup()"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|method| 714f5115_9e41_3fac_298a_669ac690c883
  3442f55b_959e_0f6f_1ec7_5a410495d6b8["teardown()"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|method| 3442f55b_959e_0f6f_1ec7_5a410495d6b8
  0fa52b64_f4c1_a5b8_af4e_a552c68a5251["writeStompFrame()"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|method| 0fa52b64_f4c1_a5b8_af4e_a552c68a5251
  a6cca428_9efa_6bd8_2508_94ec64902b5b["ChannelPromise()"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|method| a6cca428_9efa_6bd8_2508_94ec64902b5b
  fd01077d_de6b_55d4_fc1f_4208fc6c2b0b["ChainedOptionsBuilder()"]
  86cc379c_ed38_013b_cfa3_8c8e137ac012 -->|method| fd01077d_de6b_55d4_fc1f_4208fc6c2b0b

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbench/stomp/StompEncoderBenchmark.java lines 46–110

@State(Scope.Benchmark)
@Fork(value = 2)
@Threads(1)
@Warmup(iterations = 5)
@Measurement(iterations = 10)
public class StompEncoderBenchmark extends AbstractMicrobenchmark {

    private StompSubframeEncoder stompEncoder;
    private ByteBuf content;
    private StompFrame stompFrame;
    private ChannelHandlerContext context;

    @Param({ "true", "false" })
    public boolean pooledAllocator;

    @Param({ "true", "false" })
    public boolean voidPromise;

    @Param
    public ExampleStompHeadersSubframe.HeadersType headersType;

    @Param({ "0", "100", "1000" })
    public int contentLength;

    @Setup(Level.Trial)
    public void setup() {
        byte[] bytes = new byte[contentLength];
        ThreadLocalRandom.current().nextBytes(bytes);
        content = Unpooled.wrappedBuffer(bytes);
        ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());

        StompHeadersSubframe headersSubframe = ExampleStompHeadersSubframe.EXAMPLES.get(headersType);
        stompFrame = new DefaultStompFrame(headersSubframe.command(), testContent);
        stompFrame.headers().setAll(headersSubframe.headers());

        stompEncoder = new StompSubframeEncoder();
        context = new EmbeddedChannelWriteReleaseHandlerContext(
                pooledAllocator? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT, stompEncoder) {
            @Override
            protected void handleException(Throwable t) {
                handleUnexpectedException(t);
            }
        };
    }

    @TearDown(Level.Trial)
    public void teardown() {
        content.release();
        content = null;
    }

    @Benchmark
    public void writeStompFrame() throws Exception {
        stompEncoder.write(context, stompFrame.retain(), newPromise());
    }

    private ChannelPromise newPromise() {
        return voidPromise? context.voidPromise() : context.newPromise();
    }

    @Override
    protected ChainedOptionsBuilder newOptionsBuilder() throws Exception {
        return super.newOptionsBuilder().addProfiler(GCProfiler.class);
    }
}

Frequently Asked Questions

What is the StompEncoderBenchmark class?
StompEncoderBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/stomp/StompEncoderBenchmark.java.
Where is StompEncoderBenchmark defined?
StompEncoderBenchmark is defined in microbench/src/main/java/io/netty/microbench/stomp/StompEncoderBenchmark.java at line 46.

Analyze Your Own Codebase

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

Try Supermodel Free