Skip to content

Commit 9761182

Browse files
committed
remove Framework settings from Jobs, fixes #194
1 parent 61b4c18 commit 9761182

File tree

15 files changed

+27
-70
lines changed

15 files changed

+27
-70
lines changed

BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void SingleBenchmarkCanBeExecutedForMultpleRuntimes()
2626
.Run<C>(
2727
ManualConfig.CreateEmpty()
2828
.With(Job.Dry.With(Runtime.Core))
29-
.With(Job.Dry.With(Runtime.Clr).With(Framework.V46))
29+
.With(Job.Dry.With(Runtime.Clr))
3030
.With(new OutputLogger(output)));
3131

3232
Assert.True(summary.Reports

BenchmarkDotNet.Samples/Algorithms/Algo_Md5VsSha256.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class AllWindowsRuntimesConfig : ManualConfig
1111
{
1212
public AllWindowsRuntimesConfig()
1313
{
14-
Add(Job.Default.With(Runtime.Clr).With(Jit.RyuJit).With(Jobs.Framework.V40));
14+
Add(Job.Default.With(Runtime.Clr).With(Jit.RyuJit));
1515
Add(Job.Default.With(Runtime.Core).With(Jit.RyuJit));
1616
}
1717
}

BenchmarkDotNet.Samples/Intro/IntroRuntimes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private class MultipleRuntimesConfig : ManualConfig
3434
{
3535
public MultipleRuntimesConfig()
3636
{
37-
Add(Job.Dry.With(Runtime.Clr).With(Jit.RyuJit).With(Jobs.Framework.V40)); // framework for Clr must be set in explicit way
37+
Add(Job.Dry.With(Runtime.Clr).With(Jit.RyuJit));
3838
Add(Job.Dry.With(Runtime.Core).With(Jit.RyuJit));
3939
}
4040
}

BenchmarkDotNet/Columns/PropertyColumn.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public class PropertyColumn : IColumn
1111
public static readonly IColumn Mode = new PropertyColumn("Mode", benchmark => benchmark.Job.Mode.ToString());
1212
public static readonly IColumn Platform = new PropertyColumn("Platform", benchmark => benchmark.Job.Platform.ToString());
1313
public static readonly IColumn Jit = new PropertyColumn("Jit", benchmark => benchmark.Job.Jit.ToString());
14-
public static readonly IColumn Framework = new PropertyColumn("Framework", benchmark => benchmark.Job.Framework.ToString());
14+
[Obsolete("Framework setting is not supported anymore, see https://github.com/PerfDotNet/BenchmarkDotNet/issues/194 for more details", true)]
15+
public static readonly IColumn Framework = new PropertyColumn("Framework", benchmark => null);
1516
public static readonly IColumn Toolchain = new PropertyColumn("Toolchain", benchmark => Toolchains.Toolchain.GetToolchain(benchmark.Job).Name);
1617
public static readonly IColumn Runtime = new PropertyColumn("Runtime", benchmark => benchmark.Job.Runtime.ToString());
1718
public static readonly IColumn GarbageCollection = new PropertyColumn("GarbageCollection", benchmark => benchmark.Job.GarbageCollection?.ToString());

BenchmarkDotNet/Configs/DefaultConfig.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public IEnumerable<IColumn> GetColumns()
2929
yield return PropertyColumn.Mode;
3030
yield return PropertyColumn.Platform;
3131
yield return PropertyColumn.Jit;
32-
yield return PropertyColumn.Framework;
3332
yield return PropertyColumn.Toolchain;
3433
yield return PropertyColumn.Runtime;
3534
yield return PropertyColumn.GarbageCollection;

BenchmarkDotNet/Exporters/CsvMeasurementsExporter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public MeasurementColumn(string title, Func<Summary, BenchmarkReport, Measuremen
4141
new MeasurementColumn("JobMode", (summary, report, m) => report.Benchmark.Job.Mode.ToString()),
4242
new MeasurementColumn("JobPlatform", (summary, report, m) => report.Benchmark.Job.Platform.ToString()),
4343
new MeasurementColumn("JobJit", (summary, report, m) => report.Benchmark.Job.Jit.ToString()),
44-
new MeasurementColumn("JobFramework", (summary, report, m) => report.Benchmark.Job.Framework.ToString()),
4544
new MeasurementColumn("JobToolchain", (summary, report, m) => Toolchains.Toolchain.GetToolchain(report.Benchmark.Job).Name),
4645
new MeasurementColumn("JobRuntime", (summary, report, m) => report.Benchmark.Job.Runtime.ToString()),
4746

BenchmarkDotNet/Extensions/ConfigurationExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32
using BenchmarkDotNet.Jobs;
43

54
namespace BenchmarkDotNet.Extensions
@@ -23,13 +22,6 @@ public static string ToConfig(this Platform platform)
2322
}
2423
}
2524

26-
public static string ToConfig(this Framework framework)
27-
{
28-
var number = framework.ToString().Substring(1);
29-
var numberArray = number.ToCharArray().Select(c => c.ToString()).ToArray();
30-
return "v" + string.Join(".", numberArray);
31-
}
32-
3325
public static string ToConfig(this Jit jit)
3426
{
3527
return jit == Jit.LegacyJit ? "1" : "0";

BenchmarkDotNet/Jobs/Framework.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,8 @@
22

33
namespace BenchmarkDotNet.Jobs
44
{
5-
// TODO: Drop V35 in next version
5+
[Obsolete("Framework setting is not supported anymore, see https://github.com/PerfDotNet/BenchmarkDotNet/issues/194 for more details", true)]
66
public enum Framework
77
{
8-
Host,
9-
[Obsolete("BenchmarkDotNet does not support .NET 3.5", true)]
10-
V35,
11-
V40,
12-
V45,
13-
V451,
14-
V452,
15-
V46,
16-
V461,
17-
V462
188
}
199
}

BenchmarkDotNet/Jobs/IJob.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public interface IJob : IEquatable<IJob>
88
Mode Mode { get; }
99
Platform Platform { get; }
1010
Jit Jit { get; }
11-
Framework Framework { get; }
1211
IToolchain Toolchain { get; }
1312
Runtime Runtime { get; }
1413
GarbageCollection GarbageCollection { get; }

BenchmarkDotNet/Jobs/Job.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class Job : IJob
2121
public Mode Mode { get; set; } = Mode.Throughput;
2222
public Platform Platform { get; set; } = Platform.Host;
2323
public Jit Jit { get; set; } = Jit.Host;
24-
public Framework Framework { get; set; } = Framework.Host;
2524
public IToolchain Toolchain { get; set; }
2625
public Runtime Runtime { get; set; } = Runtime.Host;
2726
public GarbageCollection GarbageCollection { get; set; } = GarbageCollection.Default;

BenchmarkDotNet/Jobs/JobExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public static class JobExtensions
1111
public static IJob With(this IJob job, Mode mode) => job.With(j => j.Mode = mode);
1212
public static IJob With(this IJob job, Platform platform) => job.With(j => j.Platform = platform);
1313
public static IJob With(this IJob job, Jit jit) => job.With(j => j.Jit = jit);
14-
public static IJob With(this IJob job, Framework framework) => job.With(j => j.Framework = framework);
1514
public static IJob With(this IJob job, IToolchain toolchain) => job.With(j => j.Toolchain = toolchain);
1615
public static IJob With(this IJob job, Runtime runtime) => job.With(j => j.Runtime = runtime);
1716
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)
3534
new Property(nameof(Mode), job.Mode.ToString()),
3635
new Property(nameof(Platform), job.Platform.ToString()),
3736
new Property(nameof(Jit), job.Jit.ToString()),
38-
new Property(nameof(Framework), job.Framework.ToString()),
3937
new Property(nameof(Runtime), job.Runtime.ToString()),
4038
new Property(nameof(GarbageCollection), job.GarbageCollection?.ToString()),
4139
new Property(nameof(IJob.WarmupCount), job.WarmupCount.ToString()),
@@ -90,7 +88,6 @@ private static IJob With(this IJob job, Action<Job> set)
9088
Jit = job.Jit,
9189
Platform = job.Platform,
9290
Toolchain = job.Toolchain,
93-
Framework = job.Framework,
9491
Runtime = job.Runtime,
9592
GarbageCollection = job.GarbageCollection,
9693
Mode = job.Mode,

BenchmarkDotNet/Toolchains/Classic/ClassicToolchain.cs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,27 @@ namespace BenchmarkDotNet.Toolchains.Classic
77
{
88
public class ClassicToolchain : Toolchain
99
{
10+
// In case somebody calls ClassicToolchain from .NET Core process
11+
// we will build the project as 4.6 because it's the most safe way to do it:
12+
// * everybody that uses .NET Core must have VS 2015 installed and 4.6 is part of the installation
13+
// * from 4.6 you can target < 4.6
14+
private const string TargetFrameworkMoniker = "net46";
15+
1016
public static readonly IToolchain Instance = new ClassicToolchain();
1117

1218
private ClassicToolchain()
1319
#if CLASSIC
1420
: base("Classic", new RoslynGenerator(), new RoslynBuilder(), new ClassicExecutor())
1521
#else
1622
: base("Classic", new DotNetCliGenerator(
17-
TargetFrameworkMonikerProvider,
23+
TargetFrameworkMoniker,
1824
extraDependencies: "\"frameworkAssemblies\": { \"System.Runtime\": \"4.0.0.0\" },",
1925
platformProvider: platform => platform.ToConfig(),
2026
imports: "\"portable-net45+win8\""),
21-
new DotNetCliBuilder(TargetFrameworkMonikerProvider),
27+
new DotNetCliBuilder(TargetFrameworkMoniker),
2228
new ClassicExecutor())
2329
#endif
2430
{
2531
}
26-
27-
private static string TargetFrameworkMonikerProvider(Framework framework)
28-
{
29-
switch (framework)
30-
{
31-
case Framework.Host:
32-
throw new ArgumentException("Framework must be set");
33-
case Framework.V40:
34-
return "net40";
35-
case Framework.V45:
36-
return "net45";
37-
case Framework.V451:
38-
return "net451";
39-
case Framework.V452:
40-
return "net452";
41-
case Framework.V46:
42-
return "net46";
43-
case Framework.V461:
44-
return "net461";
45-
case Framework.V462:
46-
return "net462";
47-
default:
48-
throw new ArgumentOutOfRangeException(nameof(framework), framework, null);
49-
}
50-
}
5132
}
5233
}

BenchmarkDotNet/Toolchains/Core/CoreToolchain.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ namespace BenchmarkDotNet.Toolchains.Core
1010
{
1111
public class CoreToolchain : Toolchain
1212
{
13+
private const string TargetFrameworkMoniker = "netcoreapp1.0";
14+
1315
public static readonly IToolchain Instance = new CoreToolchain();
1416

1517
private CoreToolchain()
1618
: base("Core",
1719
new DotNetCliGenerator(
18-
GetTargetFrameworkMoniker,
20+
TargetFrameworkMoniker,
1921
GetExtraDependencies(),
2022
platformProvider: _ => "x64", // dotnet cli supports only x64 compilation now
2123
imports: GetImports(),
2224
runtime: GetRuntime()),
23-
new DotNetCliBuilder(GetTargetFrameworkMoniker),
25+
new DotNetCliBuilder(TargetFrameworkMoniker),
2426
new ClassicExecutor())
2527
{
2628
}
@@ -57,8 +59,6 @@ public override bool IsSupported(Benchmark benchmark, ILogger logger)
5759
return true;
5860
}
5961

60-
private static string GetTargetFrameworkMoniker(Framework framework) => "netcoreapp1.0";
61-
6262
private static string GetExtraDependencies()
6363
{
6464
// do not set the type to platform in order to produce exe

BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public class DotNetCliBuilder : IBuilder
1717

1818
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(2);
1919

20-
private Func<Framework, string> TargetFrameworkMonikerProvider { get; }
20+
private string TargetFrameworkMoniker { get; }
2121

22-
public DotNetCliBuilder(Func<Framework, string> targetFrameworkMonikerProvider)
22+
public DotNetCliBuilder(string targetFrameworkMoniker)
2323
{
24-
TargetFrameworkMonikerProvider = targetFrameworkMonikerProvider;
24+
TargetFrameworkMoniker = targetFrameworkMoniker;
2525
}
2626

2727
/// <summary>
@@ -40,7 +40,7 @@ public BuildResult Build(GenerateResult generateResult, ILogger logger, Benchmar
4040
}
4141

4242
if (!DotNetCliCommandExecutor.ExecuteCommand(
43-
GetBuildCommand(TargetFrameworkMonikerProvider(benchmark.Job.Framework)),
43+
GetBuildCommand(TargetFrameworkMoniker),
4444
generateResult.ArtifactsPaths.BuildArtifactsDirectoryPath,
4545
logger,
4646
DefaultTimeout))

BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliGenerator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace BenchmarkDotNet.Toolchains.DotNetCli
1111
{
1212
internal class DotNetCliGenerator : GeneratorBase
1313
{
14-
private Func<Framework, string> TargetFrameworkMonikerProvider { get; }
14+
private string TargetFrameworkMoniker { get; }
1515

1616
private string ExtraDependencies { get; }
1717

@@ -22,13 +22,13 @@ internal class DotNetCliGenerator : GeneratorBase
2222
private string Runtime { get; }
2323

2424
public DotNetCliGenerator(
25-
Func<Framework, string> targetFrameworkMonikerProvider,
25+
string targetFrameworkMoniker,
2626
string extraDependencies,
2727
Func<Platform, string> platformProvider,
2828
string imports,
2929
string runtime = null)
3030
{
31-
TargetFrameworkMonikerProvider = targetFrameworkMonikerProvider;
31+
TargetFrameworkMoniker = targetFrameworkMoniker;
3232
ExtraDependencies = extraDependencies;
3333
PlatformProvider = platformProvider;
3434
Imports = imports;
@@ -108,7 +108,7 @@ protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths arti
108108
var content = SetPlatform(template, PlatformProvider(benchmark.Job.Platform));
109109
content = SetCodeFileName(content, Path.GetFileName(artifactsPaths.ProgramCodePath));
110110
content = SetDependencyToExecutingAssembly(content, benchmark.Target.Type);
111-
content = SetTargetFrameworkMoniker(content, TargetFrameworkMonikerProvider(benchmark.Job.Framework));
111+
content = SetTargetFrameworkMoniker(content, TargetFrameworkMoniker);
112112
content = SetExtraDependencies(content, ExtraDependencies);
113113
content = SetImports(content, Imports);
114114
content = SetRuntime(content, Runtime);
@@ -120,7 +120,7 @@ protected override void GenerateProject(Benchmark benchmark, ArtifactsPaths arti
120120
protected override void GenerateBuildScript(Benchmark benchmark, ArtifactsPaths artifactsPaths)
121121
{
122122
var content = $"call dotnet {DotNetCliBuilder.RestoreCommand}{Environment.NewLine}" +
123-
$"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMonikerProvider(benchmark.Job.Framework))}";
123+
$"call dotnet {DotNetCliBuilder.GetBuildCommand(TargetFrameworkMoniker)}";
124124

125125
File.WriteAllText(artifactsPaths.BuildScriptFilePath, content);
126126
}

0 commit comments

Comments
 (0)