5
5
using System . Buffers ;
6
6
using System . IO . Pipelines ;
7
7
using System . Runtime . CompilerServices ;
8
- using System . Threading ;
9
- using System . Threading . Tasks ;
10
8
using BenchmarkDotNet . Attributes ;
11
9
using Microsoft . AspNetCore . Http . Features ;
12
10
using Microsoft . AspNetCore . Server . Kestrel . Core ;
13
- using Microsoft . AspNetCore . Server . Kestrel . Core . Internal ;
14
11
using Microsoft . AspNetCore . Server . Kestrel . Core . Internal . Http ;
15
12
using Microsoft . AspNetCore . Testing ;
16
13
@@ -22,18 +19,46 @@ public class HttpProtocolFeatureCollection
22
19
23
20
[ Benchmark ]
24
21
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
25
- public IHttpRequestFeature GetViaTypeOf_First ( )
22
+ public IHttpRequestFeature GetViaTypeOf_IHttpRequestFeature ( )
26
23
{
27
24
return ( IHttpRequestFeature ) _collection [ typeof ( IHttpRequestFeature ) ] ;
28
25
}
29
26
30
27
[ Benchmark ]
31
28
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
32
- public IHttpRequestFeature GetViaGeneric_First ( )
29
+ public IHttpRequestFeature GetViaGeneric_IHttpRequestFeature ( )
33
30
{
34
31
return _collection . Get < IHttpRequestFeature > ( ) ;
35
32
}
36
33
34
+ [ Benchmark ]
35
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
36
+ public IQueryFeature GetViaTypeOf_IQueryFeature ( )
37
+ {
38
+ return ( IQueryFeature ) _collection [ typeof ( IQueryFeature ) ] ;
39
+ }
40
+
41
+ [ Benchmark ]
42
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
43
+ public IQueryFeature GetViaGeneric_IQueryFeature ( )
44
+ {
45
+ return _collection . Get < IQueryFeature > ( ) ;
46
+ }
47
+
48
+ [ Benchmark ]
49
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
50
+ public IHttpResetFeature GetViaTypeOf_IHttpResetFeature ( )
51
+ {
52
+ return ( IHttpResetFeature ) _collection [ typeof ( IHttpResetFeature ) ] ;
53
+ }
54
+
55
+ [ Benchmark ]
56
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
57
+ public IHttpResetFeature GetViaGeneric_IHttpResetFeature ( )
58
+ {
59
+ return _collection . Get < IHttpResetFeature > ( ) ;
60
+ }
61
+
37
62
[ Benchmark ]
38
63
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
39
64
public object GetViaTypeOf_Custom ( )
0 commit comments