diff --git a/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs b/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs index 9f28956513..a6dd418ad7 100644 --- a/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs +++ b/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs @@ -26,7 +26,7 @@ public void SingleBenchmarkCanBeExecutedForMultpleRuntimes() .Run( ManualConfig.CreateEmpty() .With(Job.Dry.With(Runtime.Core)) - .With(Job.Dry.With(Runtime.Clr).With(Framework.V46)) + .With(Job.Dry.With(Runtime.Clr)) .With(new OutputLogger(output))); Assert.True(summary.Reports diff --git a/BenchmarkDotNet.Samples/Algorithms/Algo_Md5VsSha256.cs b/BenchmarkDotNet.Samples/Algorithms/Algo_Md5VsSha256.cs index 7e2ae11738..81f2f5657a 100644 --- a/BenchmarkDotNet.Samples/Algorithms/Algo_Md5VsSha256.cs +++ b/BenchmarkDotNet.Samples/Algorithms/Algo_Md5VsSha256.cs @@ -11,7 +11,7 @@ internal class AllWindowsRuntimesConfig : ManualConfig { public AllWindowsRuntimesConfig() { - Add(Job.Default.With(Runtime.Clr).With(Jit.RyuJit).With(Jobs.Framework.V40)); + Add(Job.Default.With(Runtime.Clr).With(Jit.RyuJit)); Add(Job.Default.With(Runtime.Core).With(Jit.RyuJit)); } } diff --git a/BenchmarkDotNet.Samples/Intro/IntroRuntimes.cs b/BenchmarkDotNet.Samples/Intro/IntroRuntimes.cs index 1a0f1ae85b..df32fc1c7f 100644 --- a/BenchmarkDotNet.Samples/Intro/IntroRuntimes.cs +++ b/BenchmarkDotNet.Samples/Intro/IntroRuntimes.cs @@ -34,7 +34,7 @@ private class MultipleRuntimesConfig : ManualConfig { public MultipleRuntimesConfig() { - Add(Job.Dry.With(Runtime.Clr).With(Jit.RyuJit).With(Jobs.Framework.V40)); // framework for Clr must be set in explicit way + Add(Job.Dry.With(Runtime.Clr).With(Jit.RyuJit)); Add(Job.Dry.With(Runtime.Core).With(Jit.RyuJit)); } } diff --git a/BenchmarkDotNet/Columns/PropertyColumn.cs b/BenchmarkDotNet/Columns/PropertyColumn.cs index 5adfb94da1..e015f8658c 100644 --- a/BenchmarkDotNet/Columns/PropertyColumn.cs +++ b/BenchmarkDotNet/Columns/PropertyColumn.cs @@ -11,7 +11,8 @@ public class PropertyColumn : IColumn public static readonly IColumn Mode = new PropertyColumn("Mode", benchmark => benchmark.Job.Mode.ToString()); public static readonly IColumn Platform = new PropertyColumn("Platform", benchmark => benchmark.Job.Platform.ToString()); public static readonly IColumn Jit = new PropertyColumn("Jit", benchmark => benchmark.Job.Jit.ToString()); - public static readonly IColumn Framework = new PropertyColumn("Framework", benchmark => benchmark.Job.Framework.ToString()); + [Obsolete("Framework setting is not supported anymore, see https://github.com/PerfDotNet/BenchmarkDotNet/issues/194 for more details", true)] + public static readonly IColumn Framework = new PropertyColumn("Framework", benchmark => null); public static readonly IColumn Toolchain = new PropertyColumn("Toolchain", benchmark => Toolchains.Toolchain.GetToolchain(benchmark.Job).Name); public static readonly IColumn Runtime = new PropertyColumn("Runtime", benchmark => benchmark.Job.Runtime.ToString()); public static readonly IColumn GarbageCollection = new PropertyColumn("GarbageCollection", benchmark => benchmark.Job.GarbageCollection?.ToString()); diff --git a/BenchmarkDotNet/Configs/DefaultConfig.cs b/BenchmarkDotNet/Configs/DefaultConfig.cs index c79df9b3a4..7e60f35046 100644 --- a/BenchmarkDotNet/Configs/DefaultConfig.cs +++ b/BenchmarkDotNet/Configs/DefaultConfig.cs @@ -29,7 +29,6 @@ public IEnumerable GetColumns() yield return PropertyColumn.Mode; yield return PropertyColumn.Platform; yield return PropertyColumn.Jit; - yield return PropertyColumn.Framework; yield return PropertyColumn.Toolchain; yield return PropertyColumn.Runtime; yield return PropertyColumn.GarbageCollection; diff --git a/BenchmarkDotNet/Exporters/CsvMeasurementsExporter.cs b/BenchmarkDotNet/Exporters/CsvMeasurementsExporter.cs index 51db54224f..b24d08f952 100644 --- a/BenchmarkDotNet/Exporters/CsvMeasurementsExporter.cs +++ b/BenchmarkDotNet/Exporters/CsvMeasurementsExporter.cs @@ -41,7 +41,6 @@ public MeasurementColumn(string title, Func report.Benchmark.Job.Mode.ToString()), new MeasurementColumn("JobPlatform", (summary, report, m) => report.Benchmark.Job.Platform.ToString()), new MeasurementColumn("JobJit", (summary, report, m) => report.Benchmark.Job.Jit.ToString()), - new MeasurementColumn("JobFramework", (summary, report, m) => report.Benchmark.Job.Framework.ToString()), new MeasurementColumn("JobToolchain", (summary, report, m) => Toolchains.Toolchain.GetToolchain(report.Benchmark.Job).Name), new MeasurementColumn("JobRuntime", (summary, report, m) => report.Benchmark.Job.Runtime.ToString()), diff --git a/BenchmarkDotNet/Extensions/ConfigurationExtensions.cs b/BenchmarkDotNet/Extensions/ConfigurationExtensions.cs index ece114d0ce..c868d1ce3f 100644 --- a/BenchmarkDotNet/Extensions/ConfigurationExtensions.cs +++ b/BenchmarkDotNet/Extensions/ConfigurationExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using BenchmarkDotNet.Jobs; namespace BenchmarkDotNet.Extensions @@ -23,13 +22,6 @@ public static string ToConfig(this Platform platform) } } - public static string ToConfig(this Framework framework) - { - var number = framework.ToString().Substring(1); - var numberArray = number.ToCharArray().Select(c => c.ToString()).ToArray(); - return "v" + string.Join(".", numberArray); - } - public static string ToConfig(this Jit jit) { return jit == Jit.LegacyJit ? "1" : "0"; diff --git a/BenchmarkDotNet/Jobs/Framework.cs b/BenchmarkDotNet/Jobs/Framework.cs index 6e716712a4..9b8eb1c27b 100644 --- a/BenchmarkDotNet/Jobs/Framework.cs +++ b/BenchmarkDotNet/Jobs/Framework.cs @@ -2,18 +2,8 @@ namespace BenchmarkDotNet.Jobs { - // TODO: Drop V35 in next version + [Obsolete("Framework setting is not supported anymore, see https://github.com/PerfDotNet/BenchmarkDotNet/issues/194 for more details", true)] public enum Framework { - Host, - [Obsolete("BenchmarkDotNet does not support .NET 3.5", true)] - V35, - V40, - V45, - V451, - V452, - V46, - V461, - V462 } } \ No newline at end of file diff --git a/BenchmarkDotNet/Jobs/IJob.cs b/BenchmarkDotNet/Jobs/IJob.cs index 7532a3c0d4..c964685734 100644 --- a/BenchmarkDotNet/Jobs/IJob.cs +++ b/BenchmarkDotNet/Jobs/IJob.cs @@ -8,7 +8,6 @@ public interface IJob : IEquatable Mode Mode { get; } Platform Platform { get; } Jit Jit { get; } - Framework Framework { get; } IToolchain Toolchain { get; } Runtime Runtime { get; } GarbageCollection GarbageCollection { get; } diff --git a/BenchmarkDotNet/Jobs/Job.cs b/BenchmarkDotNet/Jobs/Job.cs index c1fddaa605..f94f587486 100644 --- a/BenchmarkDotNet/Jobs/Job.cs +++ b/BenchmarkDotNet/Jobs/Job.cs @@ -21,7 +21,6 @@ public class Job : IJob public Mode Mode { get; set; } = Mode.Throughput; public Platform Platform { get; set; } = Platform.Host; public Jit Jit { get; set; } = Jit.Host; - public Framework Framework { get; set; } = Framework.Host; public IToolchain Toolchain { get; set; } public Runtime Runtime { get; set; } = Runtime.Host; public GarbageCollection GarbageCollection { get; set; } = GarbageCollection.Default; diff --git a/BenchmarkDotNet/Jobs/JobExtensions.cs b/BenchmarkDotNet/Jobs/JobExtensions.cs index 0e3c69ecc2..bc34063dec 100644 --- a/BenchmarkDotNet/Jobs/JobExtensions.cs +++ b/BenchmarkDotNet/Jobs/JobExtensions.cs @@ -11,7 +11,6 @@ public static class JobExtensions public static IJob With(this IJob job, Mode mode) => job.With(j => j.Mode = mode); public static IJob With(this IJob job, Platform platform) => job.With(j => j.Platform = platform); public static IJob With(this IJob job, Jit jit) => job.With(j => j.Jit = jit); - public static IJob With(this IJob job, Framework framework) => job.With(j => j.Framework = framework); public static IJob With(this IJob job, IToolchain toolchain) => job.With(j => j.Toolchain = toolchain); public static IJob With(this IJob job, Runtime runtime) => job.With(j => j.Runtime = runtime); public static IJob With(this IJob job, GarbageCollection garbageCollection) => job.With(j => j.GarbageCollection = garbageCollection); @@ -35,7 +34,6 @@ public static Property[] GetAllProperties(this IJob job) new Property(nameof(Mode), job.Mode.ToString()), new Property(nameof(Platform), job.Platform.ToString()), new Property(nameof(Jit), job.Jit.ToString()), - new Property(nameof(Framework), job.Framework.ToString()), new Property(nameof(Runtime), job.Runtime.ToString()), new Property(nameof(GarbageCollection), job.GarbageCollection?.ToString()), new Property(nameof(IJob.WarmupCount), job.WarmupCount.ToString()), @@ -90,7 +88,6 @@ private static IJob With(this IJob job, Action set) Jit = job.Jit, Platform = job.Platform, Toolchain = job.Toolchain, - Framework = job.Framework, Runtime = job.Runtime, GarbageCollection = job.GarbageCollection, Mode = job.Mode, diff --git a/BenchmarkDotNet/Toolchains/Classic/ClassicToolchain.cs b/BenchmarkDotNet/Toolchains/Classic/ClassicToolchain.cs index d429010cbf..c3b3c093ce 100644 --- a/BenchmarkDotNet/Toolchains/Classic/ClassicToolchain.cs +++ b/BenchmarkDotNet/Toolchains/Classic/ClassicToolchain.cs @@ -7,6 +7,12 @@ namespace BenchmarkDotNet.Toolchains.Classic { public class ClassicToolchain : Toolchain { + // In case somebody calls ClassicToolchain from .NET Core process + // we will build the project as 4.6 because it's the most safe way to do it: + // * everybody that uses .NET Core must have VS 2015 installed and 4.6 is part of the installation + // * from 4.6 you can target < 4.6 + private const string TargetFrameworkMoniker = "net46"; + public static readonly IToolchain Instance = new ClassicToolchain(); private ClassicToolchain() @@ -14,39 +20,14 @@ private ClassicToolchain() : base("Classic", new RoslynGenerator(), new RoslynBuilder(), new ClassicExecutor()) #else : base("Classic", new DotNetCliGenerator( - TargetFrameworkMonikerProvider, + TargetFrameworkMoniker, extraDependencies: "\"frameworkAssemblies\": { \"System.Runtime\": \"4.0.0.0\" },", platformProvider: platform => platform.ToConfig(), imports: "\"portable-net45+win8\""), - new DotNetCliBuilder(TargetFrameworkMonikerProvider), + new DotNetCliBuilder(TargetFrameworkMoniker), new ClassicExecutor()) #endif { } - - private static string TargetFrameworkMonikerProvider(Framework framework) - { - switch (framework) - { - case Framework.Host: - throw new ArgumentException("Framework must be set"); - case Framework.V40: - return "net40"; - case Framework.V45: - return "net45"; - case Framework.V451: - return "net451"; - case Framework.V452: - return "net452"; - case Framework.V46: - return "net46"; - case Framework.V461: - return "net461"; - case Framework.V462: - return "net462"; - default: - throw new ArgumentOutOfRangeException(nameof(framework), framework, null); - } - } } } \ No newline at end of file diff --git a/BenchmarkDotNet/Toolchains/Core/CoreToolchain.cs b/BenchmarkDotNet/Toolchains/Core/CoreToolchain.cs index f3a3617970..013780926c 100644 --- a/BenchmarkDotNet/Toolchains/Core/CoreToolchain.cs +++ b/BenchmarkDotNet/Toolchains/Core/CoreToolchain.cs @@ -10,17 +10,19 @@ namespace BenchmarkDotNet.Toolchains.Core { public class CoreToolchain : Toolchain { + private const string TargetFrameworkMoniker = "netcoreapp1.0"; + public static readonly IToolchain Instance = new CoreToolchain(); private CoreToolchain() : base("Core", new DotNetCliGenerator( - GetTargetFrameworkMoniker, + TargetFrameworkMoniker, GetExtraDependencies(), platformProvider: _ => "x64", // dotnet cli supports only x64 compilation now imports: GetImports(), runtime: GetRuntime()), - new DotNetCliBuilder(GetTargetFrameworkMoniker), + new DotNetCliBuilder(TargetFrameworkMoniker), new ClassicExecutor()) { } @@ -57,8 +59,6 @@ public override bool IsSupported(Benchmark benchmark, ILogger logger) return true; } - private static string GetTargetFrameworkMoniker(Framework framework) => "netcoreapp1.0"; - private static string GetExtraDependencies() { // do not set the type to platform in order to produce exe diff --git a/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliBuilder.cs b/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliBuilder.cs index 4252755901..cc956afcf0 100644 --- a/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliBuilder.cs +++ b/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliBuilder.cs @@ -17,11 +17,11 @@ public class DotNetCliBuilder : IBuilder private static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(2); - private Func TargetFrameworkMonikerProvider { get; } + private string TargetFrameworkMoniker { get; } - public DotNetCliBuilder(Func targetFrameworkMonikerProvider) + public DotNetCliBuilder(string targetFrameworkMoniker) { - TargetFrameworkMonikerProvider = targetFrameworkMonikerProvider; + TargetFrameworkMoniker = targetFrameworkMoniker; } /// @@ -40,7 +40,7 @@ public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmar } if (!DotNetCliCommandExecutor.ExecuteCommand( - GetBuildCommand(TargetFrameworkMonikerProvider(benchmark.Job.Framework)), + GetBuildCommand(TargetFrameworkMoniker), generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, logger, DefaultTimeout)) diff --git a/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliGenerator.cs b/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliGenerator.cs index 01d66cdf23..24b6c548f2 100644 --- a/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliGenerator.cs +++ b/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliGenerator.cs @@ -11,7 +11,7 @@ namespace BenchmarkDotNet.Toolchains.DotNetCli { internal class DotNetCliGenerator : GeneratorBase { - private Func TargetFrameworkMonikerProvider { get; } + private string TargetFrameworkMoniker { get; } private string ExtraDependencies { get; } @@ -22,13 +22,13 @@ internal class DotNetCliGenerator : GeneratorBase private string Runtime { get; } public DotNetCliGenerator( - Func targetFrameworkMonikerProvider, + string targetFrameworkMoniker, string extraDependencies, Func platformProvider, string imports, string runtime = null) { - TargetFrameworkMonikerProvider = targetFrameworkMonikerProvider; + TargetFrameworkMoniker = targetFrameworkMoniker; ExtraDependencies = extraDependencies; PlatformProvider = platformProvider; Imports = imports; @@ -108,7 +108,7 @@ protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths arti var content = SetPlatform(template, PlatformProvider(benchmark.Job.Platform)); content = SetCodeFileName(content, Path.GetFileName(artifactsPaths.ProgramCodePath)); content = SetDependencyToExecutingAssembly(content, benchmark.Target.Type); - content = SetTargetFrameworkMoniker(content, TargetFrameworkMonikerProvider(benchmark.Job.Framework)); + content = SetTargetFrameworkMoniker(content, TargetFrameworkMoniker); content = SetExtraDependencies(content, ExtraDependencies); content = SetImports(content, Imports); content = SetRuntime(content, Runtime); @@ -120,7 +120,7 @@ protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths arti protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths) { var content = $"call dotnet {DotNetCliBuilder.RestoreCommand}{Environment.NewLine}" + - $"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMonikerProvider(benchmark.Job.Framework))}"; + $"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMoniker)}"; File.WriteAllText(artifactsPaths.BuildScriptFilePath, content); }