From 10fe5e6fa25e95ab9acd2b3bd733e78be4315a37 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 10 Jan 2017 12:47:53 -0800 Subject: [PATCH] Fix performance tests --- .../configs/Core12Toolchain.cs | 64 +++++++++++++++++++ .../configs/CoreConfig.cs | 4 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/Core12Toolchain.cs diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/Core12Toolchain.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/Core12Toolchain.cs new file mode 100644 index 0000000000..d9cfdc6aca --- /dev/null +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/Core12Toolchain.cs @@ -0,0 +1,64 @@ +using System; +using System.Reflection; +using BenchmarkDotNet.Characteristics; +using BenchmarkDotNet.Environments; +using BenchmarkDotNet.Loggers; +using BenchmarkDotNet.Running; +using BenchmarkDotNet.Toolchains; +using BenchmarkDotNet.Toolchains.DotNetCli; + +namespace Microsoft.AspNetCore.Server.Kestrel.Performance +{ + public class Core12Toolchain : Toolchain + { + private const string TargetFrameworkMoniker = "netcoreapp1.1"; + + public static readonly IToolchain Instance = new Core12Toolchain(); + + public Core12Toolchain() + : base("Core12", + (IGenerator) Activator.CreateInstance(typeof(Toolchain).GetTypeInfo().Assembly.GetType("BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliGenerator"), + TargetFrameworkMoniker, + GetExtraDependencies(), + (Func) (_ => "x64"), // dotnet cli supports only x64 compilation now + GetImports(), + GetRuntime()), + new DotNetCliBuilder(TargetFrameworkMoniker), + (IExecutor) Activator.CreateInstance(typeof(Toolchain).GetTypeInfo().Assembly.GetType("BenchmarkDotNet.Toolchains.Executor"))) + { + } + + public override bool IsSupported(Benchmark benchmark, ILogger logger, IResolver resolver) + { + if (!base.IsSupported(benchmark, logger, resolver)) + { + return false; + } + + return true; + } + + private static string GetExtraDependencies() + { + // do not set the type to platform in order to produce exe + // https://github.com/dotnet/core/issues/77#issuecomment-219692312 + return "\"dependencies\": { \"Microsoft.NETCore.App\": { \"version\": \"1.2-*\" } },"; + } + + private static string GetImports() + { + return "[ \"dnxcore50\", \"portable-net45+win8\", \"dotnet5.6\", \"netcore50\" ]"; + } + + private static string GetRuntime() + { + var currentRuntime = Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment.GetRuntimeIdentifier(); ; + if (!string.IsNullOrEmpty(currentRuntime)) + { + return $"\"runtimes\": {{ \"{currentRuntime}\": {{ }} }},"; + } + + return string.Empty; + } + } +} diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs index efdf192205..97fbd2d78e 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs @@ -22,7 +22,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance With(RunStrategy.Throughput). WithLaunchCount(3). WithWarmupCount(5). - WithTargetCount(10)); + WithTargetCount(10). + With(new Core12Toolchain()) + ); } } }