From 0dca3a266fb7f6daa3698b75e27c04ccee5a58c0 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Tue, 21 Feb 2017 10:05:29 -0800 Subject: [PATCH] Remove custom BenchmarkDotNet toolchain. --- .gitignore | 1 + .../configs/CoreConfig.cs | 3 +- .../configs/MsBuildExecutor.cs | 69 ------------------- .../configs/MsBuildGenerator.cs | 61 ---------------- .../configs/MsBuildToolchain.cs | 28 -------- 5 files changed, 2 insertions(+), 160 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildExecutor.cs delete mode 100644 test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildGenerator.cs delete mode 100644 test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildToolchain.cs diff --git a/.gitignore b/.gitignore index 317cee961f..d685f8ca52 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ runtimes/ launchSettings.json BenchmarkDotNet.Artifacts/ BDN.Generated/ +binaries/ diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs index 391da34c72..1621a1ddc2 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/CoreConfig.cs @@ -22,8 +22,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance .With(RunStrategy.Throughput) .WithLaunchCount(3) .WithWarmupCount(5) - .WithTargetCount(10) - .With(new MsBuildToolchain())); + .WithTargetCount(10)); } } } diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildExecutor.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildExecutor.cs deleted file mode 100644 index c36449b6b8..0000000000 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildExecutor.cs +++ /dev/null @@ -1,69 +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 System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Reflection; -using BenchmarkDotNet.Characteristics; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Extensions; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Loggers; -using BenchmarkDotNet.Running; -using BenchmarkDotNet.Toolchains; -using BenchmarkDotNet.Toolchains.DotNetCli; -using BenchmarkDotNet.Toolchains.Results; - -namespace Microsoft.AspNetCore.Server.Kestrel.Performance -{ - public class MsBuildExecutor : IExecutor - { - public ExecuteResult Execute(BuildResult buildResult, Benchmark benchmark, ILogger logger, IResolver resolver, IDiagnoser diagnoser = null) - { - var workingDirectory = buildResult.ArtifactsPaths.BuildArtifactsDirectoryPath; - - using (var process = new Process { StartInfo = BuildDotNetProcessStartInfo(workingDirectory) }) - { - var loggerDiagnoserType = typeof(Toolchain).GetTypeInfo().Assembly.GetType("BenchmarkDotNet.Loggers.SynchronousProcessOutputLoggerWithDiagnoser"); - var loggerDiagnoser = Activator.CreateInstance( - loggerDiagnoserType, - new object[] { logger, process, diagnoser, benchmark }); - - process.Start(); - - var processInputMethodInfo = loggerDiagnoser.GetType().GetMethod("ProcessInput", BindingFlags.Instance | BindingFlags.NonPublic); - processInputMethodInfo.Invoke(loggerDiagnoser, null); - - process.WaitForExit(); - - if (process.ExitCode != 0) - { - return new ExecuteResult(true, process.ExitCode, new string[0], new string[0]); - } - - var linesWithResults = (IReadOnlyList)loggerDiagnoserType - .GetProperty("LinesWithResults", BindingFlags.Instance | BindingFlags.NonPublic) - .GetValue(loggerDiagnoser, null); - var linesWithExtraOutput = (IReadOnlyList)loggerDiagnoserType - .GetProperty("LinesWithExtraOutput", BindingFlags.Instance | BindingFlags.NonPublic) - .GetValue(loggerDiagnoser, null); - - return new ExecuteResult(true, process.ExitCode, linesWithResults, linesWithExtraOutput); - } - } - - private ProcessStartInfo BuildDotNetProcessStartInfo(string workingDirectory) - => new ProcessStartInfo - { - FileName = "dotnet", - WorkingDirectory = workingDirectory, - Arguments = "binaries/Benchmark.Generated.dll", - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildGenerator.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildGenerator.cs deleted file mode 100644 index a1bac17136..0000000000 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildGenerator.cs +++ /dev/null @@ -1,61 +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 System.IO; -using BenchmarkDotNet.Characteristics; -using BenchmarkDotNet.Environments; -using BenchmarkDotNet.Helpers; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Running; -using BenchmarkDotNet.Toolchains; -using BenchmarkDotNet.Toolchains.DotNetCli; -using System.Reflection; - -namespace Microsoft.AspNetCore.Server.Kestrel.Performance -{ - public class MsBuildGenerator : DotNetCliGenerator - { - public MsBuildGenerator() - : base("netcoreapp1.1", null, (Func) (_ => "x64"), null, null) - { - } - - protected override string GetProjectFilePath(string binariesDirectoryPath) - => Path.Combine(binariesDirectoryPath, "Benchmark.Generated.csproj"); - - protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths artifactsPaths, IResolver resolver) - { - var projectTemplate = @" - - - - - netcoreapp1.1 - true - Exe - - - - - - - - - - -"; - - var projectContent = SetCodeFileName(projectTemplate, Path.GetFileName(artifactsPaths.ProgramCodePath)); - File.WriteAllText(artifactsPaths.ProjectFilePath, projectContent); - - var runtimeConfigContent = @" -{ - ""configProperties"": { - ""System.GC.Server"": true - } -}"; - File.WriteAllText(Path.Combine(artifactsPaths.BuildArtifactsDirectoryPath, "runtimeConfig.template.json"), runtimeConfigContent); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildToolchain.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildToolchain.cs deleted file mode 100644 index a0bbda47db..0000000000 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/configs/MsBuildToolchain.cs +++ /dev/null @@ -1,28 +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.Characteristics; -using BenchmarkDotNet.Environments; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Loggers; -using BenchmarkDotNet.Running; -using BenchmarkDotNet.Toolchains; -using BenchmarkDotNet.Toolchains.Core; -using BenchmarkDotNet.Toolchains.DotNetCli; - -namespace Microsoft.AspNetCore.Server.Kestrel.Performance -{ - public class MsBuildToolchain : Toolchain - { - private const string TargetFrameworkMoniker = "netcoreapp1.1"; - - public MsBuildToolchain() - : base("MsBuildCore", - new MsBuildGenerator(), - new DotNetCliBuilder(TargetFrameworkMoniker), - new MsBuildExecutor()) - { - } - } -} \ No newline at end of file