From 346d8eaa0343cfbf6c6b64b504a46f8cf2f7de7e Mon Sep 17 00:00:00 2001 From: arespr Date: Thu, 2 Mar 2017 22:14:36 +0100 Subject: [PATCH] address PR feedback --- .../KnownStrings.cs | 4 -- .../KnownStringsTests.cs | 53 +++++++++---------- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/KnownStrings.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/KnownStrings.cs index 99b20dc8c5..240611a404 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/KnownStrings.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/KnownStrings.cs @@ -21,8 +21,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS "); static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0"); - - static byte[] _version = Encoding.UTF8.GetBytes("HTTP/1.1\r\n"); const int loops = 1000; @@ -95,7 +93,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance return GetKnownMethod(data); } - private int GetKnownMethod(Span data) { int len = 0; @@ -127,7 +124,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance return len; } - [Benchmark(OperationsPerInvoke = loops * 10)] public int GetKnownVersion_HTTP1_1() { diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/KnownStringsTests.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/KnownStringsTests.cs index f359dfae05..7c6176766e 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/KnownStringsTests.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/KnownStringsTests.cs @@ -23,7 +23,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS "); static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0"); - const int MagicNumer = 0x0600000C; static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumer); static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -38,43 +37,39 @@ namespace Microsoft.AspNetCore.Server.KestrelTests static byte[] _invalidMethod11 = Encoding.ASCII.GetBytes("OPTIONS_"); static byte[] _invalidMethod12 = Encoding.ASCII.GetBytes("TRACE_\0\0"); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] private static object[] CreateTestDataEntry(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult) { return new object[] { methodData, expectedMethod, expectedLength, expectedResult }; } - private static readonly List _testData - = new List - { - CreateTestDataEntry(_methodGet, HttpMethod.Get, 3,true), - CreateTestDataEntry(_methodPut, HttpMethod.Put, 3,true), - CreateTestDataEntry(_methodPost, HttpMethod.Post, 4,true), - CreateTestDataEntry(_methodHead, HttpMethod.Head, 4,true), - CreateTestDataEntry(_methodTrace, HttpMethod.Trace, 5,true), - CreateTestDataEntry(_methodPatch, HttpMethod.Patch, 5,true), - CreateTestDataEntry(_methodDelete, HttpMethod.Delete, 6,true), - CreateTestDataEntry(_methodConnect, HttpMethod.Connect, 7,true), - CreateTestDataEntry(_methodOptions, HttpMethod.Options, 7,true), - CreateTestDataEntry(_invalidMethod1, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod2, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod3, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod4, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod5, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod6, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod7, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod8, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod9, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod10, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod11, HttpMethod.Custom, 0,false), - CreateTestDataEntry(_invalidMethod12, HttpMethod.Custom, 0,false), - }; + private static readonly object[][] _testData = new object[][] + { + CreateTestDataEntry(_methodGet, HttpMethod.Get, 3, true), + CreateTestDataEntry(_methodPut, HttpMethod.Put, 3, true), + CreateTestDataEntry(_methodPost, HttpMethod.Post, 4, true), + CreateTestDataEntry(_methodHead, HttpMethod.Head, 4, true), + CreateTestDataEntry(_methodTrace, HttpMethod.Trace, 5, true), + CreateTestDataEntry(_methodPatch, HttpMethod.Patch, 5, true), + CreateTestDataEntry(_methodDelete, HttpMethod.Delete, 6, true), + CreateTestDataEntry(_methodConnect, HttpMethod.Connect, 7, true), + CreateTestDataEntry(_methodOptions, HttpMethod.Options, 7, true), + CreateTestDataEntry(_invalidMethod1, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod2, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod3, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod4, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod5, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod6, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod7, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod8, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod9, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod10, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod11, HttpMethod.Custom, 0, false), + CreateTestDataEntry(_invalidMethod12, HttpMethod.Custom, 0, false), + }; public static IEnumerable TestData => _testData; - [Theory] [MemberData(nameof(TestData), MemberType = typeof(KnownStringsTests))] public void GetsKnownMethod(byte[] methodData, HttpMethod expectedMethod, int expectedLength, bool expectedResult)