address PR feedback
This commit is contained in:
parent
bb74a6ce34
commit
346d8eaa03
|
|
@ -21,8 +21,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
||||||
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static byte[] _version = Encoding.UTF8.GetBytes("HTTP/1.1\r\n");
|
static byte[] _version = Encoding.UTF8.GetBytes("HTTP/1.1\r\n");
|
||||||
const int loops = 1000;
|
const int loops = 1000;
|
||||||
|
|
||||||
|
|
@ -95,7 +93,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
return GetKnownMethod(data);
|
return GetKnownMethod(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int GetKnownMethod(Span<byte> data)
|
private int GetKnownMethod(Span<byte> data)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
@ -127,7 +124,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Benchmark(OperationsPerInvoke = loops * 10)]
|
[Benchmark(OperationsPerInvoke = loops * 10)]
|
||||||
public int GetKnownVersion_HTTP1_1()
|
public int GetKnownVersion_HTTP1_1()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
|
||||||
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
|
||||||
|
|
||||||
|
|
||||||
const int MagicNumer = 0x0600000C;
|
const int MagicNumer = 0x0600000C;
|
||||||
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumer);
|
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumer);
|
||||||
static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
@ -38,16 +37,13 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
static byte[] _invalidMethod11 = Encoding.ASCII.GetBytes("OPTIONS_");
|
static byte[] _invalidMethod11 = Encoding.ASCII.GetBytes("OPTIONS_");
|
||||||
static byte[] _invalidMethod12 = Encoding.ASCII.GetBytes("TRACE_\0\0");
|
static byte[] _invalidMethod12 = Encoding.ASCII.GetBytes("TRACE_\0\0");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static object[] CreateTestDataEntry(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult)
|
private static object[] CreateTestDataEntry(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult)
|
||||||
{
|
{
|
||||||
return new object[] { methodData, expectedMethod, expectedLength, expectedResult };
|
return new object[] { methodData, expectedMethod, expectedLength, expectedResult };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly List<object[]> _testData
|
private static readonly object[][] _testData = new object[][]
|
||||||
= new List<object[]>
|
|
||||||
{
|
{
|
||||||
CreateTestDataEntry(_methodGet, HttpMethod.Get, 3, true),
|
CreateTestDataEntry(_methodGet, HttpMethod.Get, 3, true),
|
||||||
CreateTestDataEntry(_methodPut, HttpMethod.Put, 3, true),
|
CreateTestDataEntry(_methodPut, HttpMethod.Put, 3, true),
|
||||||
|
|
@ -74,7 +70,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
|
|
||||||
public static IEnumerable<object[]> TestData => _testData;
|
public static IEnumerable<object[]> TestData => _testData;
|
||||||
|
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(TestData), MemberType = typeof(KnownStringsTests))]
|
[MemberData(nameof(TestData), MemberType = typeof(KnownStringsTests))]
|
||||||
public void GetsKnownMethod(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult)
|
public void GetsKnownMethod(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue