View Javadoc
1   /*
2    * Copyright 2015 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  /*
18   * Copyright 2015 Twitter, Inc.
19   *
20   * Licensed under the Apache License, Version 2.0 (the "License");
21   * you may not use this file except in compliance with the License.
22   * You may obtain a copy of the License at
23   *
24   *     https://www.apache.org/licenses/LICENSE-2.0
25   *
26   * Unless required by applicable law or agreed to in writing, software
27   * distributed under the License is distributed on an "AS IS" BASIS,
28   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29   * See the License for the specific language governing permissions and
30   * limitations under the License.
31   */
32  package io.netty.handler.codec.http2;
33  
34  import io.netty.buffer.ByteBuf;
35  import io.netty.buffer.Unpooled;
36  
37  import java.util.List;
38  
39  /**
40   * Enum that indicates the size of the headers to be used for the benchmark.
41   */
42  public enum HpackHeadersSize {
43      SMALL(5, 20, 40),
44      MEDIUM(20, 40, 80),
45      LARGE(100, 100, 300);
46  
47      private final int numHeaders;
48      private final int nameLength;
49      private final int valueLength;
50  
51      HpackHeadersSize(int numHeaders, int nameLength, int valueLength) {
52          this.numHeaders = numHeaders;
53          this.nameLength = nameLength;
54          this.valueLength = valueLength;
55      }
56  
57      public List<HpackHeader> newHeaders(boolean limitAscii) {
58          return HpackHeader.createHeaders(numHeaders, nameLength, valueLength, limitAscii);
59      }
60  
61      public ByteBuf newOutBuffer() {
62          return Unpooled.buffer(numHeaders * (nameLength + valueLength));
63      }
64  }