From f9f80e3d80d14684ed2c77b1913cf4bd3c5a4692 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 5 Sep 2018 08:11:52 +1200 Subject: [PATCH] Revert "Add DfaMatcherBuilder benchmarks (#764)" This reverts commit ec11d0578c37bfb522d59058b0e5863140707125. --- .../Matching/MatcherAzureBenchmark.cs | 3 +- ....cs => MatcherAzureBenchmark.generated.cs} | 10 ++-- .../Matching/MatcherBuilderAzureBenchmark.cs | 31 ------------ .../Matching/MatcherBuilderGithubBenchmark.cs | 31 ------------ .../MatcherBuilderMultipleEntryBenchmark.cs | 50 ------------------- .../Matching/MatcherGithubBenchmark.cs | 2 +- ...cs => MatcherGithubBenchmark.generated.cs} | 10 ++-- tools/Swaggatherer/Template.cs | 8 +-- 8 files changed, 17 insertions(+), 128 deletions(-) rename benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/{MatcherAzureBenchmarkBase.generated.cs => MatcherAzureBenchmark.generated.cs} (99%) delete mode 100644 benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderAzureBenchmark.cs delete mode 100644 benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderGithubBenchmark.cs delete mode 100644 benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderMultipleEntryBenchmark.cs rename benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/{MatcherGithubBenchmarkBase.generated.cs => MatcherGithubBenchmark.generated.cs} (99%) diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.cs index a934316c1f..b68255e3cd 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.cs @@ -3,11 +3,12 @@ using System.Threading.Tasks; using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Http.Features; namespace Microsoft.AspNetCore.Routing.Matching { // Generated from https://github.com/Azure/azure-rest-api-specs - public class MatcherAzureBenchmark : MatcherAzureBenchmarkBase + public partial class MatcherAzureBenchmark : EndpointRoutingBenchmarkBase { private const int SampleCount = 100; diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmarkBase.generated.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.generated.cs similarity index 99% rename from benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmarkBase.generated.cs rename to benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.generated.cs index 1dc30336e3..ebb347ea51 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmarkBase.generated.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherAzureBenchmark.generated.cs @@ -7,11 +7,11 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Routing.Matching { // This code was generated by the Swaggatherer - public abstract partial class MatcherAzureBenchmarkBase : EndpointRoutingBenchmarkBase + public partial class MatcherAzureBenchmark : EndpointRoutingBenchmarkBase { - private protected const int EndpointCount = 5160; + private const int EndpointCount = 5160; - private protected void SetupEndpoints() + private void SetupEndpoints() { Endpoints = new RouteEndpoint[5160]; Endpoints[0] = CreateEndpoint("/account", "GET"); @@ -5176,7 +5176,7 @@ namespace Microsoft.AspNetCore.Routing.Matching Endpoints[5159] = CreateEndpoint("/{tenantID}/groups/{groupObjectId}/$links/members/{memberObjectId}", "DELETE"); } - private protected void SetupRequests() + private void SetupRequests() { Requests = new HttpContext[5160]; Requests[0] = new DefaultHttpContext(); @@ -25821,7 +25821,7 @@ namespace Microsoft.AspNetCore.Routing.Matching Requests[5159].Request.Path = "/67fb987d/groups/04d01a8c-6135/$links/members/71b75dbe-0076-"; } - private protected Matcher SetupMatcher(MatcherBuilder builder) + private Matcher SetupMatcher(MatcherBuilder builder) { builder.AddEndpoint(Endpoints[0]); builder.AddEndpoint(Endpoints[1]); diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderAzureBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderAzureBenchmark.cs deleted file mode 100644 index a839075c82..0000000000 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderAzureBenchmark.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using BenchmarkDotNet.Attributes; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.AspNetCore.Routing.Matching -{ - // Generated from https://github.com/APIs-guru/openapi-directory - // Use https://editor2.swagger.io/ to convert from yaml to json- - public class MatcherBuilderAzureBenchmark : MatcherAzureBenchmarkBase - { - private IServiceProvider _services; - - [GlobalSetup] - public void Setup() - { - SetupEndpoints(); - - _services = CreateServices(); - } - - [Benchmark] - public void Dfa() - { - var builder = _services.GetRequiredService(); - SetupMatcher(builder); - } - } -} \ No newline at end of file diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderGithubBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderGithubBenchmark.cs deleted file mode 100644 index 4e0244e46e..0000000000 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderGithubBenchmark.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using BenchmarkDotNet.Attributes; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.AspNetCore.Routing.Matching -{ - // Generated from https://github.com/APIs-guru/openapi-directory - // Use https://editor2.swagger.io/ to convert from yaml to json- - public class MatcherBuilderGithubBenchmark : MatcherGithubBenchmarkBase - { - private IServiceProvider _services; - - [GlobalSetup] - public void Setup() - { - SetupEndpoints(); - - _services = CreateServices(); - } - - [Benchmark] - public void Dfa() - { - var builder = _services.GetRequiredService(); - SetupMatcher(builder); - } - } -} \ No newline at end of file diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderMultipleEntryBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderMultipleEntryBenchmark.cs deleted file mode 100644 index 002118caca..0000000000 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherBuilderMultipleEntryBenchmark.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using BenchmarkDotNet.Attributes; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.AspNetCore.Routing.Matching -{ - public partial class MatcherBuilderMultipleEntryBenchmark : EndpointRoutingBenchmarkBase - { - private IServiceProvider _services; - - [GlobalSetup] - public void Setup() - { - Endpoints = new RouteEndpoint[10]; - Endpoints[0] = CreateEndpoint("/product", "GET"); - Endpoints[1] = CreateEndpoint("/product/{id}", "GET"); - - Endpoints[2] = CreateEndpoint("/account", "GET"); - Endpoints[3] = CreateEndpoint("/account/{id}"); - Endpoints[4] = CreateEndpoint("/account/{id}", "POST"); - Endpoints[5] = CreateEndpoint("/account/{id}", "UPDATE"); - - Endpoints[6] = CreateEndpoint("/v2/account", "GET"); - Endpoints[7] = CreateEndpoint("/v2/account/{id}"); - Endpoints[8] = CreateEndpoint("/v2/account/{id}", "POST"); - Endpoints[9] = CreateEndpoint("/v2/account/{id}", "UPDATE"); - - _services = CreateServices(); - } - - private Matcher SetupMatcher(MatcherBuilder builder) - { - for (int i = 0; i < Endpoints.Length; i++) - { - builder.AddEndpoint(Endpoints[i]); - } - return builder.Build(); - } - - [Benchmark] - public void Dfa() - { - var builder = _services.GetRequiredService(); - SetupMatcher(builder); - } - } -} \ No newline at end of file diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.cs index 3657b42c8b..0859fd7a72 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Routing.Matching { // Generated from https://github.com/APIs-guru/openapi-directory // Use https://editor2.swagger.io/ to convert from yaml to json- - public class MatcherGithubBenchmark : MatcherGithubBenchmarkBase + public partial class MatcherGithubBenchmark : EndpointRoutingBenchmarkBase { private BarebonesMatcher _baseline; private Matcher _dfa; diff --git a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmarkBase.generated.cs b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.generated.cs similarity index 99% rename from benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmarkBase.generated.cs rename to benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.generated.cs index 3ac68c89e0..01b2edd58f 100644 --- a/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmarkBase.generated.cs +++ b/benchmarks/Microsoft.AspNetCore.Routing.Performance/Matching/MatcherGithubBenchmark.generated.cs @@ -7,11 +7,11 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Routing.Matching { // This code was generated by the Swaggatherer - public partial class MatcherGithubBenchmarkBase : EndpointRoutingBenchmarkBase + public partial class MatcherGithubBenchmark : EndpointRoutingBenchmarkBase { - private protected const int EndpointCount = 243; + private const int EndpointCount = 243; - private protected void SetupEndpoints() + private void SetupEndpoints() { Endpoints = new RouteEndpoint[243]; Endpoints[0] = CreateEndpoint("/emojis", "GET"); @@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.Routing.Matching Endpoints[242] = CreateEndpoint("/repos/{owner}/{repo}/{archive_format}/{path}", "GET"); } - private protected void SetupRequests() + private void SetupRequests() { Requests = new HttpContext[243]; Requests[0] = new DefaultHttpContext(); @@ -1236,7 +1236,7 @@ namespace Microsoft.AspNetCore.Routing.Matching Requests[242].Request.Path = "/repos/21a74/f36c8/805b0492-b723-/680ad"; } - private protected Matcher SetupMatcher(MatcherBuilder builder) + private Matcher SetupMatcher(MatcherBuilder builder) { builder.AddEndpoint(Endpoints[0]); builder.AddEndpoint(Endpoints[1]); diff --git a/tools/Swaggatherer/Template.cs b/tools/Swaggatherer/Template.cs index 8774c6f578..c5c0c7b42e 100644 --- a/tools/Swaggatherer/Template.cs +++ b/tools/Swaggatherer/Template.cs @@ -74,21 +74,21 @@ namespace Microsoft.AspNetCore.Routing // This code was generated by the Swaggatherer public partial class GeneratedBenchmark : EndpointRoutingBenchmarkBase {{ - private protected const int EndpointCount = {3}; + private const int EndpointCount = {3}; - private protected void SetupEndpoints() + private void SetupEndpoints() {{ Endpoints = new RouteEndpoint[{3}]; {0} }} - private protected void SetupRequests() + private void SetupRequests() {{ Requests = new HttpContext[{3}]; {1} }} - private protected Matcher SetupMatcher(MatcherBuilder builder) + private Matcher SetupMatcher(MatcherBuilder builder) {{ {2} return builder.Build();