Skip to content

Instantly share code, notes, and snippets.

@alexanderkyte
Created April 24, 2019 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderkyte/78a0496b89b514ba51dc783a2e530151 to your computer and use it in GitHub Desktop.
Save alexanderkyte/78a0496b89b514ba51dc783a2e530151 to your computer and use it in GitHub Desktop.
diff --git a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs
index d4ed6a8ca..8c5d98bd9 100644
--- a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs
+++ b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs
@@ -39,15 +39,18 @@ namespace PlatformBenchmarks
private async Task ProcessRequestsAsync()
{
+ Console.WriteLine("(ProcessRequestsAsync {0})", System.Environment.StackTrace);
while (true)
{
var task = Reader.ReadAsync();
+ Console.WriteLine("(ProcessRequestsAsyncOne)");
if (!task.IsCompleted)
{
// No more data in the input
await OnReadCompletedAsync();
}
+ Console.WriteLine("(ProcessRequestsAsyncOne) read completed");
var result = await task;
var buffer = result.Buffer;
@@ -55,12 +58,15 @@ namespace PlatformBenchmarks
{
if (!ParseHttpRequest(ref buffer, result.IsCompleted, out var examined))
{
+ Console.WriteLine("(ProcessRequestsAsyncOne) can't parse request");
return;
}
if (_state == State.Body)
{
+ Console.WriteLine("(ProcessRequestsAsyncOne) Before process async");
await ProcessRequestAsync();
+ Console.WriteLine("(ProcessRequestsAsyncOne) After process async");
_state = State.StartLine;
@@ -85,39 +91,56 @@ namespace PlatformBenchmarks
var consumed = buffer.Start;
var state = _state;
+ Console.WriteLine ("Parse HTTP Request");
+
if (!buffer.IsEmpty)
{
+ Console.WriteLine ("Not empty");
+
+ Console.WriteLine ("Check startline");
if (state == State.StartLine)
{
+ Console.WriteLine ("ParseRequestLine");
if (Parser.ParseRequestLine(new ParsingAdapter(this), buffer, out consumed, out examined))
{
state = State.Headers;
}
+ Console.WriteLine ("ParseRequestLine consumed {0}", consumed.GetInteger ());
buffer = buffer.Slice(consumed);
}
+ Console.WriteLine ("Check headers");
if (state == State.Headers)
{
+ Console.WriteLine ("ParseHeaders");
if (Parser.ParseHeaders(new ParsingAdapter(this), buffer, out consumed, out examined, out int consumedBytes))
{
state = State.Body;
}
+ Console.WriteLine ("ParseHeaders consumed {0}", consumed.GetInteger ());
buffer = buffer.Slice(consumed);
}
+ Console.WriteLine ("Check body");
if (state != State.Body && isCompleted)
{
+ Console.WriteLine ("Unexpected end of data");
ThrowUnexpectedEndOfData();
}
+
+ Console.WriteLine ("End of not empty");
}
else if (isCompleted)
{
+ Console.WriteLine ("isCompleted");
return false;
}
+ Console.WriteLine ("State update");
_state = state;
+ Console.WriteLine ("done");
return true;
}
@@ -178,4 +201,4 @@ namespace PlatformBenchmarks
}
}
-}
\ No newline at end of file
+}
diff --git a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.PlainText.cs b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.PlainText.cs
index 0339ffeb2..ee122ea3e 100644
--- a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.PlainText.cs
+++ b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.PlainText.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.IO;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Text.Encodings.Web;
@@ -15,30 +16,45 @@ namespace PlatformBenchmarks
{
private static void PlainText(PipeWriter pipeWriter)
{
+ Console.WriteLine (System.Environment.StackTrace);
+
+ Console.WriteLine ("Line 1");
var writer = GetWriter(pipeWriter);
// HTTP 1.1 OK
+ Console.WriteLine ("Line 2");
writer.Write(_http11OK);
// Server headers
+ Console.WriteLine ("Line 3");
writer.Write(_headerServer);
// Date header
+ Console.WriteLine ("Line 4");
writer.Write(DateHeader.HeaderBytes);
// Content-Type header
+ Console.WriteLine ("Line 5");
writer.Write(_headerContentTypeText);
// Content-Length header
+ Console.WriteLine ("Line 6");
writer.Write(_headerContentLength);
+ Console.WriteLine ("Line 7");
writer.WriteNumeric((uint)_plainTextBody.Length);
+ Console.WriteLine ("Line 8");
// End of headers
+ Console.WriteLine ("Line 9");
writer.Write(_eoh);
+ Console.WriteLine ("Line 10");
// Body
+ Console.WriteLine ("Line 11");
writer.Write(_plainTextBody);
+ Console.WriteLine ("Line 12");
writer.Commit();
+ Console.WriteLine ("Line 13");
}
}
}
diff --git a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.cs b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.cs
index 6f5702d76..62ad7263a 100644
--- a/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.cs
+++ b/frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/BenchmarkApplication.cs
@@ -104,6 +104,7 @@ namespace PlatformBenchmarks
public Task ProcessRequestAsync()
{
+ Console.WriteLine("(ProcessRequestAsync {0})", System.Environment.StackTrace);
var requestType = _requestType;
if (requestType == RequestType.PlainText)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment