|
14 | 14 |
|
15 | 15 | namespace PlatformBenchmarks
|
16 | 16 | {
|
17 |
| - public partial class BenchmarkApplication |
| 17 | + public sealed partial class BenchmarkApplication |
18 | 18 | {
|
19 |
| - private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application"; |
20 |
| - public static AsciiString ApplicationName => _applicationName; |
21 |
| - |
22 |
| - private readonly static AsciiString _crlf = "\r\n"; |
23 |
| - private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r\n"; |
24 |
| - private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r\n"; |
25 |
| - private readonly static AsciiString _headerServer = "Server: K"; |
26 |
| - private readonly static AsciiString _headerContentLength = "Content-Length: "; |
27 |
| - private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0"; |
28 |
| - private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain"; |
29 |
| - private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json"; |
30 |
| - |
31 |
| - private readonly static AsciiString _dbPreamble = |
32 |
| - _http11OK + |
33 |
| - _headerServer + _crlf + |
34 |
| - _headerContentTypeJson + _crlf + |
35 |
| - _headerContentLength; |
36 |
| - |
37 |
| - private readonly static AsciiString _plainTextBody = "Hello, World!"; |
38 |
| - private readonly static AsciiString _contentLengthGap = new string(' ', 4); |
| 19 | + public static ReadOnlySpan<byte> ApplicationName => "Kestrel Platform-Level Application"u8; |
| 20 | + |
| 21 | + private static ReadOnlySpan<byte> _crlf => "\r\n"u8; |
| 22 | + private static ReadOnlySpan<byte> _eoh => "\r\n\r\n"u8; // End Of Headers |
| 23 | + private static ReadOnlySpan<byte> _http11OK => "HTTP/1.1 200 OK\r\n"u8; |
| 24 | + private static ReadOnlySpan<byte> _http11NotFound => "HTTP/1.1 404 Not Found\r\n"u8; |
| 25 | + private static ReadOnlySpan<byte> _headerServer => "Server: K"u8; |
| 26 | + private static ReadOnlySpan<byte> _headerContentLength => "Content-Length: "u8; |
| 27 | + private static ReadOnlySpan<byte> _headerContentLengthZero => "Content-Length: 0"u8; |
| 28 | + private static ReadOnlySpan<byte> _headerContentTypeText => "Content-Type: text/plain"u8; |
| 29 | + private static ReadOnlySpan<byte> _headerContentTypeJson => "Content-Type: application/json"u8; |
| 30 | + private static ReadOnlySpan<byte> _headerContentTypeHtml => "Content-Type: text/html; charset=UTF-8"u8; |
| 31 | + |
| 32 | + private static ReadOnlySpan<byte> _dbPreamble => |
| 33 | + "HTTP/1.1 200 OK\r\n"u8 + |
| 34 | + "Server: K\r\n"u8 + |
| 35 | + "Content-Type: application/json\r\n"u8 + |
| 36 | + "Content-Length: "u8; |
| 37 | + |
| 38 | + private static ReadOnlySpan<byte> _plainTextBody => "Hello, World!"u8; |
| 39 | + private static ReadOnlySpan<byte> _contentLengthGap => " "u8; |
39 | 40 |
|
40 | 41 | public static RawDb RawDb { get; set; }
|
41 | 42 | public static DapperDb DapperDb { get; set; }
|
@@ -74,15 +75,15 @@ private partial class JsonContext : JsonSerializerContext
|
74 | 75 |
|
75 | 76 | public static class Paths
|
76 | 77 | {
|
77 |
| - public readonly static AsciiString Json = "/json"; |
78 |
| - public readonly static AsciiString Plaintext = "/plaintext"; |
79 |
| - public readonly static AsciiString SingleQuery = "/db"; |
80 |
| - public readonly static AsciiString FortunesRaw = "/fortunes"; |
81 |
| - public readonly static AsciiString FortunesDapper = "/fortunes/dapper"; |
82 |
| - public readonly static AsciiString FortunesEf = "/fortunes/ef"; |
83 |
| - public readonly static AsciiString Updates = "/updates/"; |
84 |
| - public readonly static AsciiString MultipleQueries = "/queries/"; |
85 |
| - public readonly static AsciiString Caching = "/cached-worlds/"; |
| 78 | + public static ReadOnlySpan<byte> Json => "/json"u8; |
| 79 | + public static ReadOnlySpan<byte> Plaintext => "/plaintext"u8; |
| 80 | + public static ReadOnlySpan<byte> SingleQuery => "/db"u8; |
| 81 | + public static ReadOnlySpan<byte> FortunesRaw => "/fortunes"u8; |
| 82 | + public static ReadOnlySpan<byte> FortunesDapper => "/fortunes/dapper"u8; |
| 83 | + public static ReadOnlySpan<byte> FortunesEf => "/fortunes/ef"u8; |
| 84 | + public static ReadOnlySpan<byte> Updates => "/updates/"u8; |
| 85 | + public static ReadOnlySpan<byte> MultipleQueries => "/queries/"u8; |
| 86 | + public static ReadOnlySpan<byte> Caching => "/cached-worlds/"u8; |
86 | 87 | }
|
87 | 88 |
|
88 | 89 | private RequestType _requestType;
|
@@ -191,11 +192,11 @@ private static Task Default(PipeWriter pipeWriter)
|
191 | 192 | return Task.CompletedTask;
|
192 | 193 | }
|
193 | 194 | #endif
|
194 |
| - private readonly static AsciiString _defaultPreamble = |
195 |
| - _http11NotFound + |
196 |
| - _headerServer + _crlf + |
197 |
| - _headerContentTypeText + _crlf + |
198 |
| - _headerContentLengthZero; |
| 195 | + private static ReadOnlySpan<byte> _defaultPreamble => |
| 196 | + "HTTP/1.1 200 OK\r\n"u8 + |
| 197 | + "Server: K"u8 + "\r\n"u8 + |
| 198 | + "Content-Type: text/plain"u8 + |
| 199 | + "Content-Length: 0"u8; |
199 | 200 |
|
200 | 201 | private static void Default(ref BufferWriter<WriterAdapter> writer)
|
201 | 202 | {
|
|
0 commit comments