made benchmark work

This commit is contained in:
Tom Gardham-Pallister 2018-09-25 21:02:13 +01:00
parent 2d834037e4
commit 65b4115e90
2 changed files with 31 additions and 22 deletions

View File

@ -27,6 +27,7 @@ using BenchmarkDotNet.Validators;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.Middleware.Multiplexer;
using Ocelot.Configuration;
namespace Ocelot.Benchmarks
{
@ -54,7 +55,6 @@ namespace Ocelot.Benchmarks
var services = serviceCollection.BuildServiceProvider();
var loggerFactory = services.GetService<IOcelotLoggerFactory>();
var drpf = services.GetService<IDownstreamRouteProviderFactory>();
var icr = services.GetService<IInternalConfigurationRepository>();
var multiplexer = services.GetService<IMultiplexer>();
_next = async context => {
@ -62,8 +62,16 @@ namespace Ocelot.Benchmarks
throw new Exception("BOOM");
};
_middleware = new DownstreamRouteFinderMiddleware(_next, loggerFactory, drpf, icr, multiplexer);
_downstreamContext = new DownstreamContext(new DefaultHttpContext());
_middleware = new DownstreamRouteFinderMiddleware(_next, loggerFactory, drpf, multiplexer);
var httpContext = new DefaultHttpContext();
httpContext.Request.Path = new PathString("/test");
httpContext.Request.QueryString = new QueryString("?a=b");
httpContext.Request.Headers.Add("Host", "most");
_downstreamContext = new DownstreamContext(httpContext)
{
Configuration = new InternalConfiguration(new List<ReRoute>(), null, null, null, null, null, null, null)
};
}
[Benchmark(Baseline = true)]

View File

@ -10,7 +10,8 @@ namespace Ocelot.Benchmarks
typeof(DictionaryBenchmarks),
typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
typeof(AllTheThingsBenchmarks),
typeof(ExceptionHandlerMiddlewareBenchmarks)
typeof(ExceptionHandlerMiddlewareBenchmarks),
typeof(DownstreamRouteFinderMiddlewareBenchmarks)
});
switcher.Run(args);