Fix broken microbenchmarks (#1861).

This commit is contained in:
Cesar Blum Silveira 2017-05-25 16:01:17 -07:00 committed by GitHub
parent 6c0af445e5
commit 009759c7f6
7 changed files with 38 additions and 17 deletions

View File

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
namespace Microsoft.AspNetCore.Server.Kestrel.Performance namespace Microsoft.AspNetCore.Server.Kestrel.Performance
{ {
@ -84,7 +85,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
var frameContext = new FrameContext var frameContext = new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation() ConnectionInformation = new MockConnectionInformation
{
PipeFactory = new PipeFactory()
}
}; };
_frame = new Frame<object>(application: null, frameContext: frameContext); _frame = new Frame<object>(application: null, frameContext: frameContext);

View File

@ -29,7 +29,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
var frameContext = new FrameContext var frameContext = new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation(), ConnectionInformation = new MockConnectionInformation
{
PipeFactory = new PipeFactory()
},
TimeoutControl = new MockTimeoutControl() TimeoutControl = new MockTimeoutControl()
}; };

View File

@ -75,9 +75,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
private TestFrame<object> MakeFrame() private TestFrame<object> MakeFrame()
{ {
var factory = new PipeFactory(); var pipeFactory = new PipeFactory();
var input = factory.Create(); var input = pipeFactory.Create();
var output = factory.Create(); var output = pipeFactory.Create();
var serviceContext = new ServiceContext var serviceContext = new ServiceContext
{ {
@ -90,7 +90,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
var frame = new TestFrame<object>(application: null, context: new FrameContext var frame = new TestFrame<object>(application: null, context: new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation(), ConnectionInformation = new MockConnectionInformation
{
PipeFactory = pipeFactory
},
Input = input.Reader, Input = input.Reader,
Output = output Output = output
}); });

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
public IPEndPoint RemoteEndPoint { get; } public IPEndPoint RemoteEndPoint { get; }
public IPEndPoint LocalEndPoint { get; } public IPEndPoint LocalEndPoint { get; }
public PipeFactory PipeFactory { get; } public PipeFactory PipeFactory { get; set; }
public bool RequiresDispatch { get; } public bool RequiresDispatch { get; }
public IScheduler InputWriterScheduler { get; } public IScheduler InputWriterScheduler { get; }
public IScheduler OutputReaderScheduler { get; } public IScheduler OutputReaderScheduler { get; }

View File

@ -17,26 +17,30 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
public Frame<object> Frame { get; set; } public Frame<object> Frame { get; set; }
public PipeFactory PipelineFactory { get; set; } public PipeFactory PipeFactory { get; set; }
[Setup] [Setup]
public void Setup() public void Setup()
{ {
PipeFactory = new PipeFactory();
Pipe = PipeFactory.Create();
var serviceContext = new ServiceContext var serviceContext = new ServiceContext
{ {
HttpParserFactory = f => new HttpParser<FrameAdapter>(), HttpParserFactory = f => new HttpParser<FrameAdapter>(),
ServerOptions = new KestrelServerOptions() ServerOptions = new KestrelServerOptions(),
}; };
var frameContext = new FrameContext var frameContext = new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation(), ConnectionInformation = new MockConnectionInformation
{
PipeFactory = PipeFactory
},
TimeoutControl = new MockTimeoutControl() TimeoutControl = new MockTimeoutControl()
}; };
Frame = new Frame<object>(application: null, frameContext: frameContext); Frame = new Frame<object>(application: null, frameContext: frameContext);
PipelineFactory = new PipeFactory();
Pipe = PipelineFactory.Create();
} }
[Benchmark(Baseline = true, OperationsPerInvoke = RequestParsingData.InnerLoopCount)] [Benchmark(Baseline = true, OperationsPerInvoke = RequestParsingData.InnerLoopCount)]

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines;
namespace Microsoft.AspNetCore.Server.Kestrel.Performance namespace Microsoft.AspNetCore.Server.Kestrel.Performance
{ {
@ -176,7 +177,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
var frameContext = new FrameContext var frameContext = new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation() ConnectionInformation = new MockConnectionInformation
{
PipeFactory = new PipeFactory()
}
}; };
var frame = new Frame<object>(application: null, frameContext: frameContext); var frame = new Frame<object>(application: null, frameContext: frameContext);

View File

@ -110,9 +110,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
[Setup] [Setup]
public void Setup() public void Setup()
{ {
var factory = new PipeFactory(); var pipeFactory = new PipeFactory();
var input = factory.Create(); var input = pipeFactory.Create();
var output = factory.Create(); var output = pipeFactory.Create();
var serviceContext = new ServiceContext var serviceContext = new ServiceContext
{ {
@ -125,7 +125,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
var frame = new TestFrame<object>(application: null, context: new FrameContext var frame = new TestFrame<object>(application: null, context: new FrameContext
{ {
ServiceContext = serviceContext, ServiceContext = serviceContext,
ConnectionInformation = new MockConnectionInformation(), ConnectionInformation = new MockConnectionInformation
{
PipeFactory = pipeFactory
},
TimeoutControl = new MockTimeoutControl(), TimeoutControl = new MockTimeoutControl(),
Input = input.Reader, Input = input.Reader,
Output = output Output = output