Home / Class/ IntObjectHashMapBenchmark Class — netty Architecture

IntObjectHashMapBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  d5e026a1_aecf_2ae4_507b_59a3d0b64104["IntObjectHashMapBenchmark"]
  6db8a76f_31e4_5c67_7f35_99ab8043f7cc["IntObjectHashMapBenchmark.java"]
  d5e026a1_aecf_2ae4_507b_59a3d0b64104 -->|defined in| 6db8a76f_31e4_5c67_7f35_99ab8043f7cc
  3e170e47_faa3_4529_0528_46737aa392fa["setup()"]
  d5e026a1_aecf_2ae4_507b_59a3d0b64104 -->|method| 3e170e47_faa3_4529_0528_46737aa392fa
  67bfcbdb_0565_118f_9633_5c3fa4df15d9["put()"]
  d5e026a1_aecf_2ae4_507b_59a3d0b64104 -->|method| 67bfcbdb_0565_118f_9633_5c3fa4df15d9
  507dd91f_c2d8_4085_4f54_73340da351d8["lookup()"]
  d5e026a1_aecf_2ae4_507b_59a3d0b64104 -->|method| 507dd91f_c2d8_4085_4f54_73340da351d8
  ddd64a42_02ac_8907_e1ff_a99d45415629["remove()"]
  d5e026a1_aecf_2ae4_507b_59a3d0b64104 -->|method| ddd64a42_02ac_8907_e1ff_a99d45415629

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java lines 32–192

public class IntObjectHashMapBenchmark extends AbstractMicrobenchmark {
    private static final Long VALUE = Long.MAX_VALUE;

    public enum MapType {
        AGRONA,
        NETTY
    }

    public enum KeyDistribution {
        HTTP2,
        RANDOM
    }

    @Param({ "10", "100", "1000", "10000", "100000" })
    public int size;

    @Param
    public MapType mapType;

    @Param
    public KeyDistribution keyDistribution;

    private Environment environment;

    @Setup(Level.Trial)
    public void setup() {
        switch(mapType) {
            case AGRONA: {
                environment = new AgronaEnvironment();
                break;
            }
            case NETTY: {
                environment = new NettyEnvironment();
                break;
            }
            default: {
                throw new IllegalStateException("Invalid mapType: " + mapType);
            }
        }
    }

    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    public void put(Blackhole bh) {
        environment.put(bh);
    }

    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    public void lookup(Blackhole bh) {
        environment.lookup(bh);
    }

    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    public void remove(Blackhole bh) {
        environment.remove(bh);
    }

    private abstract class Environment {
        final int[] keys;
        Environment() {
            keys = new int[size];
            switch(keyDistribution) {
                case HTTP2:
                    for (int index = 0, key = 3; index < size; ++index, key += 2) {
                        keys[index] = key;
                    }
                    break;
                case RANDOM: {
                    // Create a 'size' # of random integers.
                    Random r = new Random();
                    Set<Integer> keySet = new HashSet<Integer>();
                    while (keySet.size() < size) {
                        keySet.add(r.nextInt());
                    }

                    int index = 0;
                    for (Integer key : keySet) {
                        keys[index++] = key;
                    }

Frequently Asked Questions

What is the IntObjectHashMapBenchmark class?
IntObjectHashMapBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java.
Where is IntObjectHashMapBenchmark defined?
IntObjectHashMapBenchmark is defined in microbench/src/main/java/io/netty/microbenchmark/common/IntObjectHashMapBenchmark.java at line 32.

Analyze Your Own Codebase

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

Try Supermodel Free