Home / Function/ init() — netty Function Reference

init() — netty Function Reference

Architecture documentation for the init() function in RandomSizeByteBufAllocationBenchmark.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ac43d053_55dd_7df8_1331_931e702fcb96["init()"]
  8839dc57_30e1_9514_ff04_baa254ce09fc["RandomSizeByteBufAllocationBenchmark"]
  ac43d053_55dd_7df8_1331_931e702fcb96 -->|defined in| 8839dc57_30e1_9514_ff04_baa254ce09fc
  style ac43d053_55dd_7df8_1331_931e702fcb96 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbench/buffer/RandomSizeByteBufAllocationBenchmark.java lines 88–121

    @Setup
    public void init() {
        if (!(Thread.currentThread() instanceof FastThreadLocalThread)) {
            throw new IllegalStateException("This benchmark must be run with FastThreadLocalThread: run it with: " +
        "-Djmh.executor=CUSTOM -Djmh.executor.class=io.netty.microbench.util.AbstractMicrobenchmark$HarnessExecutor");
        }
        switch (allocatorType) {
        case JEMALLOC:
            allocator = new PooledByteBufAllocator(true);
            break;
        case ADAPTIVE:
            allocator = new AdaptiveByteBufAllocator(true, true);
            break;
        default:
            throw new IllegalArgumentException("Unknown allocator type: " + allocatorType);
        }
        samples = MathUtil.findNextPositivePowerOfTwo(samples);
        sampleMask = samples - 1;
        sizeSamples = new short[samples];
        SplittableRandom rnd = new SplittableRandom(SEED);
        // here we're not using random size [0, 16896] because if the size class is too large
        // it has more chances to be picked!
        for (int i = 0; i < samples; i++) {
            // pick a random size class
            int sizeClass = rnd.nextInt(SIZE_CLASSES.length);
            // now pick a random size within the size class
            short size =
                    (short) rnd.nextInt(sizeClass == 0? 0 : SIZE_CLASSES[sizeClass - 1] + 1, SIZE_CLASSES[sizeClass]);
            if (size < 0) {
                throw new IllegalArgumentException("Size sample out of range: " + size);
            }
            sizeSamples[i] = size;
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does init() do?
init() is a function in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/buffer/RandomSizeByteBufAllocationBenchmark.java.
Where is init() defined?
init() is defined in microbench/src/main/java/io/netty/microbench/buffer/RandomSizeByteBufAllocationBenchmark.java at line 88.

Analyze Your Own Codebase

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

Try Supermodel Free