Remove our custom bootstrapper and use the BenchmarkSwitcher (#1480)
This commit is contained in:
parent
3c8ee39f1d
commit
f479720d5a
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using BenchmarkDotNet.Running;
|
using BenchmarkDotNet.Running;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
|
|
@ -10,62 +11,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var options = (uint[])Enum.GetValues(typeof(BenchmarkType));
|
BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RunSelectedBenchmarks(BenchmarkType type)
|
|
||||||
{
|
|
||||||
if (type.HasFlag(BenchmarkType.RequestParsing))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<RequestParsing>();
|
|
||||||
}
|
|
||||||
if (type.HasFlag(BenchmarkType.Writing))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<Writing>();
|
|
||||||
}
|
|
||||||
if (type.HasFlag(BenchmarkType.Throughput))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<PipeThroughput>();
|
|
||||||
}
|
|
||||||
if (type.HasFlag(BenchmarkType.KnownStrings))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<KnownStrings>();
|
|
||||||
}
|
|
||||||
if (type.HasFlag(BenchmarkType.KestrelHttpParser))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<KestrelHttpParser>();
|
|
||||||
}
|
|
||||||
if (type.HasFlag(BenchmarkType.FrameParsingOverhead))
|
|
||||||
{
|
|
||||||
BenchmarkRunner.Run<FrameParsingOverhead>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue