HttpMethodMapBenchmark Class — netty Architecture
Architecture documentation for the HttpMethodMapBenchmark class in HttpMethodMapBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 850ae674_6e21_4c44_21cd_02af9a8adf48["HttpMethodMapBenchmark"] fb58d464_e70b_796d_4f8b_0f59cab8b4e1["HttpMethodMapBenchmark.java"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|defined in| fb58d464_e70b_796d_4f8b_0f59cab8b4e1 6891ed33_19a8_fc85_5128_aacf49052803["oldMapKnownMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| 6891ed33_19a8_fc85_5128_aacf49052803 f54bf40b_194d_5204_581c_775913d36d88["newMapKnownMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| f54bf40b_194d_5204_581c_775913d36d88 6395a650_395e_5bf9_846c_8824a11de461["oldMapMixMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| 6395a650_395e_5bf9_846c_8824a11de461 e82d08d5_510f_df6f_b5af_4413ffd6beb1["newMapMixMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| e82d08d5_510f_df6f_b5af_4413ffd6beb1 b4f918cf_b437_03c1_96b9_571a3c2d04cb["oldMapUnknownMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| b4f918cf_b437_03c1_96b9_571a3c2d04cb 3a018ff6_a483_fe89_7f9f_0f9bb2f4b0a2["newMapUnknownMethods()"] 850ae674_6e21_4c44_21cd_02af9a8adf48 -->|method| 3a018ff6_a483_fe89_7f9f_0f9bb2f4b0a2
Relationship Graph
Source Code
microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java lines 42–207
@State(Scope.Benchmark)
@Warmup(iterations = 5)
@Measurement(iterations = 8)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class HttpMethodMapBenchmark extends AbstractMicrobenchmark {
private static final Map<String, HttpMethod> OLD_MAP = new HashMap<String, HttpMethod>();
private static final SimpleStringMap<HttpMethod> NEW_MAP;
private static final String[] KNOWN_METHODS;
private static final String[] MIXED_METHODS;
private static final String[] UNKNOWN_METHODS;
static {
// We intentionally don't use HttpMethod.toString() here to avoid the equals(..) comparison method from being
// able to short circuit due to reference equality checks and being biased toward the new approach. This
// simulates the behavior of HttpObjectDecoder which will build new String objects during the decode operation.
KNOWN_METHODS = new String[] {
"OPTIONS",
"GET",
"HEAD",
"POST",
"PUT",
"PATCH",
"DELETE",
"TRACE",
"CONNECT"
};
MIXED_METHODS = new String[] {
"OPTIONS",
"FAKEMETHOD",
"GET",
"HEAD",
"POST",
"UBERGET",
"PUT",
"PATCH",
"MYMETHOD",
"DELETE",
"TRACE",
"CONNECT",
"WHATMETHOD"
};
UNKNOWN_METHODS = new String[] {
"FAKEMETHOD",
"UBERGET",
"MYMETHOD",
"TESTING",
"WHATMETHOD",
"UNKNOWN",
"FOOBAR"
};
OLD_MAP.put(OPTIONS.toString(), OPTIONS);
OLD_MAP.put(GET.toString(), GET);
OLD_MAP.put(HEAD.toString(), HEAD);
OLD_MAP.put(POST.toString(), POST);
OLD_MAP.put(PUT.toString(), PUT);
OLD_MAP.put(PATCH.toString(), PATCH);
OLD_MAP.put(DELETE.toString(), DELETE);
OLD_MAP.put(TRACE.toString(), TRACE);
OLD_MAP.put(CONNECT.toString(), CONNECT);
NEW_MAP = new SimpleStringMap<HttpMethod>(
new SimpleStringMap.Node<HttpMethod>(OPTIONS.toString(), OPTIONS),
new SimpleStringMap.Node<HttpMethod>(GET.toString(), GET),
new SimpleStringMap.Node<HttpMethod>(HEAD.toString(), HEAD),
new SimpleStringMap.Node<HttpMethod>(POST.toString(), POST),
new SimpleStringMap.Node<HttpMethod>(PUT.toString(), PUT),
new SimpleStringMap.Node<HttpMethod>(PATCH.toString(), PATCH),
new SimpleStringMap.Node<HttpMethod>(DELETE.toString(), DELETE),
new SimpleStringMap.Node<HttpMethod>(TRACE.toString(), TRACE),
new SimpleStringMap.Node<HttpMethod>(CONNECT.toString(), CONNECT));
}
private static final class SimpleStringMap<T> {
private final SimpleStringMap.Node<T>[] values;
private final int valuesMask;
SimpleStringMap(SimpleStringMap.Node<T>... nodes) {
values = (SimpleStringMap.Node<T>[]) new SimpleStringMap.Node[findNextPositivePowerOfTwo(nodes.length)];
valuesMask = values.length - 1;
for (SimpleStringMap.Node<T> node : nodes) {
int i = hashCode(node.key) & valuesMask;
Source
Frequently Asked Questions
What is the HttpMethodMapBenchmark class?
HttpMethodMapBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java.
Where is HttpMethodMapBenchmark defined?
HttpMethodMapBenchmark is defined in microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free