Home / Class/ ByteBufUtilDecodeStringBenchmark Class — netty Architecture

ByteBufUtilDecodeStringBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  eb34c265_3af6_0692_7076_c5e6ce28d473["ByteBufUtilDecodeStringBenchmark"]
  35bda7ea_11d0_140e_24ee_2d761506a72f["ByteBufUtilDecodeStringBenchmark.java"]
  eb34c265_3af6_0692_7076_c5e6ce28d473 -->|defined in| 35bda7ea_11d0_140e_24ee_2d761506a72f
  f64dcac3_905c_082f_c8f0_b4a4d70eab81["jvmArgs()"]
  eb34c265_3af6_0692_7076_c5e6ce28d473 -->|method| f64dcac3_905c_082f_c8f0_b4a4d70eab81
  47e67797_8bfd_3c51_273f_cf1cac3b63b1["setup()"]
  eb34c265_3af6_0692_7076_c5e6ce28d473 -->|method| 47e67797_8bfd_3c51_273f_cf1cac3b63b1
  57b25aa6_08ab_b7f5_1269_353fdfe3f6c4["teardown()"]
  eb34c265_3af6_0692_7076_c5e6ce28d473 -->|method| 57b25aa6_08ab_b7f5_1269_353fdfe3f6c4
  e377fb49_c551_ee5a_a841_310fc049aaf7["String()"]
  eb34c265_3af6_0692_7076_c5e6ce28d473 -->|method| e377fb49_c551_ee5a_a841_310fc049aaf7

Relationship Graph

Source Code

microbench/src/main/java/io/netty/buffer/ByteBufUtilDecodeStringBenchmark.java lines 30–121

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

    public enum ByteBufType {
        DIRECT {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                ByteBuf buffer = Unpooled.directBuffer(length);
                buffer.writeBytes(bytes, 0, length);
                return buffer;
            }
        },
        HEAP_OFFSET {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return Unpooled.wrappedBuffer(bytes, 1, length);
            }
        },
        HEAP {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return Unpooled.wrappedBuffer(bytes, 0, length);
            }
        },
        COMPOSITE {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                CompositeByteBuf buffer = Unpooled.compositeBuffer();
                int offset = 0;
                // 8 buffers per composite.
                int capacity = length / 8;

                while (length > 0) {
                    buffer.addComponent(true, Unpooled.wrappedBuffer(bytes, offset, Math.min(length, capacity)));
                    length -= capacity;
                    offset += capacity;
                }
                return buffer;
            }
        };

        abstract ByteBuf newBuffer(byte[] bytes, int length);
    }

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

    @Param({
            "US-ASCII",
            "UTF-8",
    })
    public String charsetName;

    @Param
    public ByteBufType bufferType;

    private ByteBuf buffer;
    private Charset charset;

    @Override
    protected String[] jvmArgs() {
        // Ensure we minimize the GC overhead by sizing the heap big enough.
        return new String[] { "-XX:MaxDirectMemorySize=2g", "-Xmx8g", "-Xms8g", "-Xmn6g" };
    }

    @Setup
    public void setup() {
        byte[] bytes = new byte[size + 2];
        Arrays.fill(bytes, (byte) 'a');

        // Use an offset to not allow any optimizations because we use the exact passed in byte[] for heap buffers.
        buffer = bufferType.newBuffer(bytes, size);
        charset = Charset.forName(charsetName);
    }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free