Add benchmark that drains the buffer without going through the pipe (#1611)
This commit is contained in:
parent
adea477824
commit
bab4332a47
|
|
@ -67,6 +67,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Benchmark(OperationsPerInvoke = RequestParsingData.InnerLoopCount * RequestParsingData.Pipelining)]
|
||||||
|
public void PipelinedPlaintextTechEmpowerDrainBuffer()
|
||||||
|
{
|
||||||
|
for (var i = 0; i < RequestParsingData.InnerLoopCount; i++)
|
||||||
|
{
|
||||||
|
InsertData(RequestParsingData.PlaintextTechEmpowerPipelinedRequests);
|
||||||
|
ParseDataDrainBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Benchmark(OperationsPerInvoke = RequestParsingData.InnerLoopCount)]
|
[Benchmark(OperationsPerInvoke = RequestParsingData.InnerLoopCount)]
|
||||||
public void LiveAspNet()
|
public void LiveAspNet()
|
||||||
{
|
{
|
||||||
|
|
@ -115,6 +125,41 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
buffer.FlushAsync().GetAwaiter().GetResult();
|
buffer.FlushAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ParseDataDrainBuffer()
|
||||||
|
{
|
||||||
|
var awaitable = Pipe.Reader.ReadAsync();
|
||||||
|
if (!awaitable.IsCompleted)
|
||||||
|
{
|
||||||
|
// No more data
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var readableBuffer = awaitable.GetResult().Buffer;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Frame.Reset();
|
||||||
|
|
||||||
|
if (!Frame.TakeStartLine(readableBuffer, out var consumed, out var examined))
|
||||||
|
{
|
||||||
|
ErrorUtilities.ThrowInvalidRequestLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
readableBuffer = readableBuffer.Slice(consumed);
|
||||||
|
|
||||||
|
Frame.InitializeHeaders();
|
||||||
|
|
||||||
|
if (!Frame.TakeMessageHeaders(readableBuffer, out consumed, out examined))
|
||||||
|
{
|
||||||
|
ErrorUtilities.ThrowInvalidRequestHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
readableBuffer = readableBuffer.Slice(consumed);
|
||||||
|
}
|
||||||
|
while (readableBuffer.Length > 0);
|
||||||
|
|
||||||
|
Pipe.Reader.Advance(readableBuffer.End);
|
||||||
|
}
|
||||||
|
|
||||||
private void ParseData()
|
private void ParseData()
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue