Home / Class/ HeadersBenchmark Class — netty Architecture

HeadersBenchmark Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  c899cf50_c3df_329e_10dd_da3e80b77ee7["HeadersBenchmark"]
  e80a2612_ee38_6e60_9211_68969b05075e["HeadersBenchmark.java"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|defined in| e80a2612_ee38_6e60_9211_68969b05075e
  5a1b1223_058d_2bb4_3375_4775b9cf96ae["String()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 5a1b1223_058d_2bb4_3375_4775b9cf96ae
  a1f8ecf4_fc82_e3a2_e6b3_a88966442c08["setup()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| a1f8ecf4_fc82_e3a2_e6b3_a88966442c08
  cddad251_bbea_ebfb_f27e_c3b81fce2513["httpRemove()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| cddad251_bbea_ebfb_f27e_c3b81fce2513
  a66040ed_443d_5909_5318_891312e06b87["httpGet()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| a66040ed_443d_5909_5318_891312e06b87
  d19f2da0_799e_c770_66c6_af6d86dc839d["httpContainsValueIgnoreCase()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| d19f2da0_799e_c770_66c6_af6d86dc839d
  5b93c64a_c76e_d6aa_2dca_269d1d048525["httpContainsValueIgnoreCaseNonExisting()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 5b93c64a_c76e_d6aa_2dca_269d1d048525
  2f559737_5ee0_1a42_192a_9e3b43334307["containsValue()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 2f559737_5ee0_1a42_192a_9e3b43334307
  82b3b5a1_720e_f239_b313_67004da8dace["DefaultHttpHeaders()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 82b3b5a1_720e_f239_b313_67004da8dace
  383381b9_c6b0_d26f_e453_9628ba9badb8["httpIterate()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 383381b9_c6b0_d26f_e453_9628ba9badb8
  a3bf4cd3_6508_dbc7_057d_44e99cfe8632["http2Remove()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| a3bf4cd3_6508_dbc7_057d_44e99cfe8632
  8c6ce17b_36d2_8c74_4c7b_229b15d985fa["http2Get()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 8c6ce17b_36d2_8c74_4c7b_229b15d985fa
  0acc99fa_7bd5_65d8_ec59_aadbd0e90adb["DefaultHttp2Headers()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| 0acc99fa_7bd5_65d8_ec59_aadbd0e90adb
  d3a5b1dc_3a2a_b9b6_fbfa_9e462e2b40c5["http2Iterate()"]
  c899cf50_c3df_329e_10dd_da3e80b77ee7 -->|method| d3a5b1dc_3a2a_b9b6_fbfa_9e462e2b40c5

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbench/headers/HeadersBenchmark.java lines 46–744

@Threads(1)
@State(Scope.Benchmark)
@Fork(1)
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class HeadersBenchmark extends AbstractMicrobenchmark {

    private static String toHttpName(String name) {
        return (name.startsWith(":")) ? name.substring(1) : name;
    }

    static String toHttp2Name(String name) {
        name = name.toLowerCase();
        return (name.equals("host")) ? "xhost" : name;
    }

    @Param
    ExampleHeaders.HeaderExample exampleHeader;

    AsciiString[] httpNames;
    AsciiString[] http2Names;
    AsciiString[] httpValues;
    AsciiString[] httpWrongValues;

    DefaultHttpHeaders httpHeaders;
    DefaultHttp2Headers http2Headers;
    DefaultHttpHeaders emptyHttpHeaders;
    DefaultHttp2Headers emptyHttp2Headers;
    DefaultHttpHeaders emptyHttpHeadersNoValidate;
    DefaultHttp2Headers emptyHttp2HeadersNoValidate;
    SlowHeaders slowHttp2Headers;

    @Setup(Level.Trial)
    public void setup() {
        Map<String, String> headers = ExampleHeaders.EXAMPLES.get(exampleHeader);
        httpNames = new AsciiString[headers.size()];
        http2Names = new AsciiString[headers.size()];
        httpValues = new AsciiString[headers.size()];
        httpWrongValues = new AsciiString[headers.size()];
        httpHeaders = new DefaultHttpHeaders(false);
        http2Headers = new DefaultHttp2Headers(false);
        int idx = 0;
        for (Map.Entry<String, String> header : headers.entrySet()) {
            String name = header.getKey();
            String httpName = toHttpName(name);
            String http2Name = toHttp2Name(name);
            String value = header.getValue();
            httpNames[idx] = new AsciiString(httpName);
            http2Names[idx] = new AsciiString(http2Name);
            httpValues[idx] = new AsciiString(value);
            // make it wrong by appending "wrong"
            httpWrongValues[idx] = new AsciiString(value + "wrong");
            httpHeaders.add(httpNames[idx], httpValues[idx]);
            http2Headers.add(http2Names[idx], httpValues[idx]);
            idx++;
        }
        slowHttp2Headers = new SlowHeaders(http2Headers);
        emptyHttpHeaders = new DefaultHttpHeaders(true);
        emptyHttp2Headers = new DefaultHttp2Headers(true);
        emptyHttpHeadersNoValidate = new DefaultHttpHeaders(false);
        emptyHttp2HeadersNoValidate = new DefaultHttp2Headers(false);
    }

    @Benchmark
    @BenchmarkMode(Mode.AverageTime)
    public void httpRemove(Blackhole bh) {
        for (AsciiString name : httpNames) {
            bh.consume(httpHeaders.remove(name));
        }
    }

    @Benchmark
    @BenchmarkMode(Mode.AverageTime)
    public void httpGet(Blackhole bh) {
        for (AsciiString name : httpNames) {
            bh.consume(httpHeaders.get(name));
        }
    }

    @Benchmark

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free