From f479720d5a9eb7759e235cf94134dcdb93e87784 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 11 Mar 2017 18:19:13 -0800 Subject: [PATCH] Remove our custom bootstrapper and use the BenchmarkSwitcher (#1480) --- .../Program.cs | 58 +------------------ 1 file changed, 2 insertions(+), 56 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Program.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Program.cs index 95ca5909db..8a8d9c6d68 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Program.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Program.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.Reflection; using BenchmarkDotNet.Running; namespace Microsoft.AspNetCore.Server.Kestrel.Performance @@ -10,62 +11,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance { public static void Main(string[] args) { - var options = (uint[])Enum.GetValues(typeof(BenchmarkType)); - BenchmarkType type; - if (args.Length != 1 || !Enum.TryParse(args[0], out type)) - { - Console.WriteLine($"Please add benchmark to run as parameter:"); - for (var i = 0; i < options.Length; i++) - { - Console.WriteLine($" {((BenchmarkType)options[i]).ToString()}"); - } - - return; - } - - RunSelectedBenchmarks(type); + BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args); } - - private static void RunSelectedBenchmarks(BenchmarkType type) - { - if (type.HasFlag(BenchmarkType.RequestParsing)) - { - BenchmarkRunner.Run(); - } - if (type.HasFlag(BenchmarkType.Writing)) - { - BenchmarkRunner.Run(); - } - if (type.HasFlag(BenchmarkType.Throughput)) - { - BenchmarkRunner.Run(); - } - if (type.HasFlag(BenchmarkType.KnownStrings)) - { - BenchmarkRunner.Run(); - } - if (type.HasFlag(BenchmarkType.KestrelHttpParser)) - { - BenchmarkRunner.Run(); - } - if (type.HasFlag(BenchmarkType.FrameParsingOverhead)) - { - BenchmarkRunner.Run(); - } - } - } - - [Flags] - public enum BenchmarkType : uint - { - RequestParsing = 1, - Writing = 2, - Throughput = 4, - KnownStrings = 8, - KestrelHttpParser = 16, - FrameParsingOverhead = 32, - // add new ones in powers of two - e.g. 2,4,8,16... - - All = uint.MaxValue } }