@@ -14,27 +14,27 @@ namespace PlatformBenchmarks;
14
14
15
15
public partial class BenchmarkApplication
16
16
{
17
- private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application" ;
18
- public static AsciiString ApplicationName => _applicationName ;
19
-
20
- private readonly static AsciiString _crlf = "\r \n " ;
21
- private readonly static AsciiString _eoh = "\r \n \r \n " ; // End Of Headers
22
- private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r \n " ;
23
- private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r \n " ;
24
- private readonly static AsciiString _headerServer = "Server: K" ;
25
- private readonly static AsciiString _headerContentLength = "Content-Length: " ;
26
- private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0" ;
27
- private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain" ;
28
- private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json" ;
29
- private readonly static AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8" ;
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!" ;
17
+ private static ReadOnlySpan < byte > _applicationName => "Kestrel Platform-Level Application"u8 ;
18
+ public static ReadOnlySpan < byte > ApplicationName => _applicationName ;
19
+
20
+ private static ReadOnlySpan < byte > _crlf => "\r \n "u8 ;
21
+ private static ReadOnlySpan < byte > _eoh => "\r \n \r \n "u8 ; // End Of Headers
22
+ private static ReadOnlySpan < byte > _http11OK => "HTTP/1.1 200 OK\r \n "u8 ;
23
+ private static ReadOnlySpan < byte > _http11NotFound => "HTTP/1.1 404 Not Found\r \n "u8 ;
24
+ private static ReadOnlySpan < byte > _headerServer => "Server: K"u8 ;
25
+ private static ReadOnlySpan < byte > _headerContentLength => "Content-Length: "u8 ;
26
+ private static ReadOnlySpan < byte > _headerContentLengthZero => "Content-Length: 0"u8 ;
27
+ private static ReadOnlySpan < byte > _headerContentTypeText => "Content-Type: text/plain"u8 ;
28
+ private static ReadOnlySpan < byte > _headerContentTypeJson => "Content-Type: application/json"u8 ;
29
+ private static ReadOnlySpan < byte > _headerContentTypeHtml => "Content-Type: text/html; charset=UTF-8"u8 ;
30
+
31
+ private static ReadOnlySpan < byte > _dbPreamble =>
32
+ "HTTP/1.1 200 OK \r \n "u8 +
33
+ "Server: K \r \n "u8 +
34
+ "Content-Type: application/json \r \n "u8 +
35
+ "Content-Length: "u8 ;
36
+
37
+ private static ReadOnlySpan < byte > _plainTextBody => "Hello, World!"u8 ;
38
38
39
39
private static readonly JsonContext SerializerContext = JsonContext . Default ;
40
40
@@ -46,12 +46,12 @@ private sealed partial class JsonContext : JsonSerializerContext
46
46
{
47
47
}
48
48
49
- private readonly static AsciiString _fortunesTableStart = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>" ;
50
- private readonly static AsciiString _fortunesRowStart = "<tr><td>" ;
51
- private readonly static AsciiString _fortunesColumn = "</td><td>" ;
52
- private readonly static AsciiString _fortunesRowEnd = "</td></tr>" ;
53
- private readonly static AsciiString _fortunesTableEnd = "</table></body></html>" ;
54
- private readonly static AsciiString _contentLengthGap = new string ( ' ' , 4 ) ;
49
+ private static ReadOnlySpan < byte > _fortunesTableStart => "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"u8 ;
50
+ private static ReadOnlySpan < byte > _fortunesRowStart => "<tr><td>"u8 ;
51
+ private static ReadOnlySpan < byte > _fortunesColumn => "</td><td>"u8 ;
52
+ private static ReadOnlySpan < byte > _fortunesRowEnd => "</td></tr>"u8 ;
53
+ private static ReadOnlySpan < byte > _fortunesTableEnd => "</table></body></html>"u8 ;
54
+ private static ReadOnlySpan < byte > _contentLengthGap => " "u8 ;
55
55
56
56
#if DATABASE
57
57
public static RawDb Db { get ; set ; }
@@ -62,13 +62,13 @@ private sealed partial class JsonContext : JsonSerializerContext
62
62
63
63
public static class Paths
64
64
{
65
- public readonly static AsciiString Json = "/json" ;
66
- public readonly static AsciiString Plaintext = "/plaintext" ;
67
- public readonly static AsciiString SingleQuery = "/db" ;
68
- public readonly static AsciiString Fortunes = "/fortunes" ;
69
- public readonly static AsciiString Updates = "/updates/" ;
70
- public readonly static AsciiString MultipleQueries = "/queries/" ;
71
- public readonly static AsciiString Caching = "/cached-worlds/" ;
65
+ public static ReadOnlySpan < byte > Json => "/json"u8 ;
66
+ public static ReadOnlySpan < byte > Plaintext => "/plaintext"u8 ;
67
+ public static ReadOnlySpan < byte > SingleQuery => "/db"u8 ;
68
+ public static ReadOnlySpan < byte > Fortunes => "/fortunes"u8 ;
69
+ public static ReadOnlySpan < byte > Updates => "/updates/"u8 ;
70
+ public static ReadOnlySpan < byte > MultipleQueries => "/queries/"u8 ;
71
+ public static ReadOnlySpan < byte > Caching => "/cached-worlds/"u8 ;
72
72
}
73
73
74
74
private RequestType _requestType ;
@@ -169,11 +169,11 @@ private static Task Default(PipeWriter pipeWriter)
169
169
return Task . CompletedTask ;
170
170
}
171
171
#endif
172
- private readonly static AsciiString _defaultPreamble =
173
- _http11NotFound +
174
- _headerServer + _crlf +
175
- _headerContentTypeText + _crlf +
176
- _headerContentLengthZero ;
172
+ private static ReadOnlySpan < byte > _defaultPreamble =>
173
+ "HTTP/1.1 200 OK \r \n "u8 +
174
+ "Server: K"u8 + " \r \n "u8 +
175
+ "Content-Type: text/plain"u8 +
176
+ "Content-Length: 0"u8 ;
177
177
178
178
private static void Default ( ref BufferWriter < WriterAdapter > writer )
179
179
{
0 commit comments