Skip to content

Commit 82b7d3e

Browse files
committed
Tweaks
1 parent 5741ac7 commit 82b7d3e

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/BenchmarksApps/TechEmpower/Kestrel/BenchmarkApp.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Buffers;
2+
using System.Runtime.CompilerServices;
23
using System.Text;
34
using System.Text.Json;
45
using System.Text.Json.Serialization;
@@ -35,35 +36,24 @@ public Task ProcessRequestAsync(IFeatureCollection features)
3536
{
3637
return Json(res, features);
3738
}
38-
else if (pathSpan.StartsWith("json-string", StringComparison.OrdinalIgnoreCase))
39+
else if (Paths.IsPath(pathSpan, Paths.JsonString))
3940
{
4041
return JsonString(res, features);
4142
}
42-
else if (pathSpan.StartsWith("json-utf8bytes", StringComparison.OrdinalIgnoreCase))
43+
else if (Paths.IsPath(pathSpan, Paths.JsonUtf8Bytes))
4344
{
4445
return JsonUtf8Bytes(res, features);
4546
}
46-
else if (pathSpan.StartsWith("json-chunked", StringComparison.OrdinalIgnoreCase))
47+
else if (Paths.IsPath(pathSpan, Paths.JsonChunked))
4748
{
4849
return JsonChunked(res, features);
4950
}
50-
else if (pathSpan.IsEmpty || pathSpan.Equals("/", StringComparison.OrdinalIgnoreCase))
51+
else if (pathSpan.IsEmpty || Paths.IsPath(pathSpan, Paths.Index))
5152
{
5253
return Index(res, features);
5354
}
5455

5556
return NotFound(res, features);
56-
57-
//return req.Path switch
58-
//{
59-
// "/plaintext" => Plaintext(res, features),
60-
// "/json" => Json(res, features),
61-
// "/json-string" => JsonString(res, features),
62-
// "/json-utf8bytes" => JsonUtf8Bytes(res, features),
63-
// "/json-chunked" => JsonChunked(res, features),
64-
// "/" => Index(res, features),
65-
// _ => NotFound(res, features),
66-
//};
6757
}
6858

6959
private static Task NotFound(IHttpResponseFeature res, IFeatureCollection features)
@@ -160,8 +150,8 @@ private static async Task Json(IHttpResponseFeature res, IFeatureCollection feat
160150

161151
body.Writer.Write(messageSpan);
162152

163-
await body.StartAsync();
164-
await body.Writer.FlushAsync();
153+
//await body.StartAsync();
154+
//await body.Writer.FlushAsync();
165155
}
166156

167157
[ThreadStatic]
@@ -201,7 +191,12 @@ private static class Paths
201191
{
202192
public static ReadOnlySpan<char> Plaintext => "/plaintext";
203193
public static ReadOnlySpan<char> Json => "/json";
194+
public static ReadOnlySpan<char> JsonString => "/json-string";
195+
public static ReadOnlySpan<char> JsonChunked => "/json-chunked";
196+
public static ReadOnlySpan<char> JsonUtf8Bytes => "/json-utf8bytes";
197+
public static ReadOnlySpan<char> Index => "/";
204198

199+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
205200
public static bool IsPath(ReadOnlySpan<char> path, ReadOnlySpan<char> targetPath) => path.SequenceEqual(targetPath);
206201
}
207202
}

src/BenchmarksApps/TechEmpower/Kestrel/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
{
2424
socketOptions.IOQueueCount = value;
2525
}
26+
var kestrelOptions = new KestrelServerOptions();
27+
kestrelOptions.Limits.MinRequestBodyDataRate = null;
28+
kestrelOptions.Limits.MinResponseDataRate = null;
29+
2630
using var server = new KestrelServer(
27-
Options.Create(new KestrelServerOptions()),
31+
Options.Create(kestrelOptions),
2832
new SocketTransportFactory(Options.Create(socketOptions), loggerFactory),
2933
loggerFactory
3034
);

0 commit comments

Comments
 (0)