Home / Class/ CompositeByteBufSequentialBenchmark Class — netty Architecture

CompositeByteBufSequentialBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  a31cbcd2_284d_80df_b419_f14bc59b12cf["CompositeByteBufSequentialBenchmark"]
  172e8c5f_48e3_3a1e_8525_39a725b1f1d9["CompositeByteBufSequentialBenchmark.java"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|defined in| 172e8c5f_48e3_3a1e_8525_39a725b1f1d9
  d8d5045d_2781_3afd_9327_3c3fbe87328b["setup()"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|method| d8d5045d_2781_3afd_9327_3c3fbe87328b
  378a736a_e61c_ed0e_e162_05799fc650b4["teardown()"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|method| 378a736a_e61c_ed0e_e162_05799fc650b4
  cff93f70_418f_07af_ba79_ba9e8fa87d3f["forEachByte()"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|method| cff93f70_418f_07af_ba79_ba9e8fa87d3f
  723fb62b_cc8e_9352_3afe_f8c6b3c2724b["sequentialWriteAndRead()"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|method| 723fb62b_cc8e_9352_3afe_f8c6b3c2724b
  a0bb53b3_7532_650f_d4d1_c2843acddb34["ByteBuf()"]
  a31cbcd2_284d_80df_b419_f14bc59b12cf -->|method| a0bb53b3_7532_650f_d4d1_c2843acddb34

Relationship Graph

Source Code

microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java lines 35–139

@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
public class CompositeByteBufSequentialBenchmark extends AbstractMicrobenchmark {

    public enum ByteBufType {
        SMALL_CHUNKS {
            @Override
            ByteBuf newBuffer(int length) {
                return newBufferSmallChunks(length);
            }
        },
        LARGE_CHUNKS {
            @Override
            ByteBuf newBuffer(int length) {
                return newBufferLargeChunks(length);
            }
        };
        abstract ByteBuf newBuffer(int length);
    }

    @Param({
            "8",
            "64",
            "1024",
            "10240",
            "102400",
            "1024000",
    })
    public int size;

    @Param
    public ByteBufType bufferType;

    private ByteBuf buffer;

    @Setup
    public void setup() {
        buffer = bufferType.newBuffer(size);
    }

    @TearDown
    public void teardown() {
        buffer.release();
    }

    private static final ByteProcessor TEST_PROCESSOR = new ByteProcessor() {
        @Override
        public boolean process(byte value) throws Exception {
            return value == 'b'; // false
        }
    };

    @Benchmark
    public int forEachByte() {
        buffer.setIndex(0, buffer.capacity());
        buffer.forEachByte(TEST_PROCESSOR);
        return buffer.forEachByteDesc(TEST_PROCESSOR);
    }

    @Benchmark
    public int sequentialWriteAndRead() {
        buffer.clear();
        for (int i = 0, l = buffer.writableBytes(); i < l; i++) {
            buffer.writeByte('a');
        }
        for (int i = 0, l = buffer.readableBytes(); i < l; i++) {
            if (buffer.readByte() == 'b') {
                return -1;
            }
        }
        return 1;
    }

    private static ByteBuf newBufferSmallChunks(int length) {

        List<ByteBuf> buffers = new ArrayList<ByteBuf>(((length + 1) / 45) * 19);
        for (int i = 0; i < length + 45; i += 45) {
            for (int j = 1; j <= 9; j++) {
                buffers.add(EMPTY_BUFFER);
                buffers.add(wrappedBuffer(new byte[j]));
            }

Frequently Asked Questions

What is the CompositeByteBufSequentialBenchmark class?
CompositeByteBufSequentialBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java.
Where is CompositeByteBufSequentialBenchmark defined?
CompositeByteBufSequentialBenchmark is defined in microbench/src/main/java/io/netty/buffer/CompositeByteBufSequentialBenchmark.java at line 35.

Analyze Your Own Codebase

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

Try Supermodel Free