From 009759c7f68010bff72f6dac28f3573680fd6ba6 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Thu, 25 May 2017 16:01:17 -0700 Subject: [PATCH] Fix broken microbenchmarks (#1861). --- .../FrameFeatureCollection.cs | 6 +++++- .../FrameParsingOverheadBenchmark.cs | 5 ++++- .../FrameWritingBenchmark.cs | 11 +++++++---- .../Mocks/MockConnectionInformation.cs | 2 +- .../RequestParsingBenchmark.cs | 14 +++++++++----- .../ResponseHeaderCollectionBenchmark.cs | 6 +++++- .../ResponseHeadersWritingBenchmark.cs | 11 +++++++---- 7 files changed, 38 insertions(+), 17 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameFeatureCollection.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameFeatureCollection.cs index bd4ec5ae97..3d699f795f 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameFeatureCollection.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameFeatureCollection.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines; namespace Microsoft.AspNetCore.Server.Kestrel.Performance { @@ -84,7 +85,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var frameContext = new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation() + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = new PipeFactory() + } }; _frame = new Frame(application: null, frameContext: frameContext); diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameParsingOverheadBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameParsingOverheadBenchmark.cs index 71964abb79..6128d3c955 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameParsingOverheadBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameParsingOverheadBenchmark.cs @@ -29,7 +29,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var frameContext = new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation(), + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = new PipeFactory() + }, TimeoutControl = new MockTimeoutControl() }; diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameWritingBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameWritingBenchmark.cs index ff1a3b5298..5eea9eafb2 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameWritingBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/FrameWritingBenchmark.cs @@ -75,9 +75,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance private TestFrame MakeFrame() { - var factory = new PipeFactory(); - var input = factory.Create(); - var output = factory.Create(); + var pipeFactory = new PipeFactory(); + var input = pipeFactory.Create(); + var output = pipeFactory.Create(); var serviceContext = new ServiceContext { @@ -90,7 +90,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var frame = new TestFrame(application: null, context: new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation(), + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = pipeFactory + }, Input = input.Reader, Output = output }); diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockConnectionInformation.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockConnectionInformation.cs index 2cec8398a0..e02bd98be2 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockConnectionInformation.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Mocks/MockConnectionInformation.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance public IPEndPoint RemoteEndPoint { get; } public IPEndPoint LocalEndPoint { get; } - public PipeFactory PipeFactory { get; } + public PipeFactory PipeFactory { get; set; } public bool RequiresDispatch { get; } public IScheduler InputWriterScheduler { get; } public IScheduler OutputReaderScheduler { get; } diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/RequestParsingBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/RequestParsingBenchmark.cs index c6d5e5263c..c88f9408b2 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/RequestParsingBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/RequestParsingBenchmark.cs @@ -17,26 +17,30 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance public Frame Frame { get; set; } - public PipeFactory PipelineFactory { get; set; } + public PipeFactory PipeFactory { get; set; } [Setup] public void Setup() { + PipeFactory = new PipeFactory(); + Pipe = PipeFactory.Create(); + var serviceContext = new ServiceContext { HttpParserFactory = f => new HttpParser(), - ServerOptions = new KestrelServerOptions() + ServerOptions = new KestrelServerOptions(), }; var frameContext = new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation(), + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = PipeFactory + }, TimeoutControl = new MockTimeoutControl() }; Frame = new Frame(application: null, frameContext: frameContext); - PipelineFactory = new PipeFactory(); - Pipe = PipelineFactory.Create(); } [Benchmark(Baseline = true, OperationsPerInvoke = RequestParsingData.InnerLoopCount)] diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs index 7a65a7d7a6..f4d894a645 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines; namespace Microsoft.AspNetCore.Server.Kestrel.Performance { @@ -176,7 +177,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var frameContext = new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation() + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = new PipeFactory() + } }; var frame = new Frame(application: null, frameContext: frameContext); diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeadersWritingBenchmark.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeadersWritingBenchmark.cs index 659b903a8e..1daf1b7e45 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeadersWritingBenchmark.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/ResponseHeadersWritingBenchmark.cs @@ -110,9 +110,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance [Setup] public void Setup() { - var factory = new PipeFactory(); - var input = factory.Create(); - var output = factory.Create(); + var pipeFactory = new PipeFactory(); + var input = pipeFactory.Create(); + var output = pipeFactory.Create(); var serviceContext = new ServiceContext { @@ -125,7 +125,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance var frame = new TestFrame(application: null, context: new FrameContext { ServiceContext = serviceContext, - ConnectionInformation = new MockConnectionInformation(), + ConnectionInformation = new MockConnectionInformation + { + PipeFactory = pipeFactory + }, TimeoutControl = new MockTimeoutControl(), Input = input.Reader, Output = output