Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide columns for multiple runtime #1621

Merged
merged 6 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/BenchmarkDotNet/Columns/JobCharacteristicColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private JobCharacteristicColumn(Characteristic characteristic)

public string Id { get; }
public string ColumnName { get; }
public bool IsAvailable(Summary summary) => true;
public bool AlwaysShow => false;
public ColumnCategory Category => ColumnCategory.Job;
public int PriorityInCategory => 0;
Expand All @@ -38,6 +37,23 @@ private JobCharacteristicColumn(Characteristic characteristic)

public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => !benchmarkCase.Job.HasValue(characteristic);

public bool IsAvailable(Summary summary)
{
if (summary.IsMultipleRuntimes)
{
if (nameof(Toolchains.Toolchain).Equals(ColumnName))
{
return false;
}
if (nameof(Job).Equals(ColumnName))
{
return summary.BenchmarksCases.Any(x => x.Job.HasValue(CharacteristicObject.IdCharacteristic));
}
}

return true;
}

public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
{
if (!benchmarkCase.Job.HasValue(characteristic) && EnvironmentResolver.Instance.CanResolve(characteristic))
Expand Down
10 changes: 7 additions & 3 deletions src/BenchmarkDotNet/Reports/Summary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public class Summary
[PublicAPI] public ImmutableArray<BenchmarkCase> BenchmarksCases { get; }
[PublicAPI] public ImmutableArray<BenchmarkReport> Reports { get; }

private ImmutableDictionary<BenchmarkCase, BenchmarkReport> ReportMap {get; }
private BaseliningStrategy BaseliningStrategy {get; }

internal DisplayPrecisionManager DisplayPrecisionManager { get; }

private ImmutableDictionary<BenchmarkCase, BenchmarkReport> ReportMap { get; }
private BaseliningStrategy BaseliningStrategy { get; }
private bool? isMultipleRuntimes;

public Summary(
string title,
ImmutableArray<BenchmarkReport> reports,
Expand Down Expand Up @@ -75,6 +76,9 @@ public Summary(

public int GetNumberOfExecutedBenchmarks() => Reports.Count(report => report.ExecuteResults.Any(result => result.FoundExecutable));

public bool IsMultipleRuntimes
=> isMultipleRuntimes ??= BenchmarksCases.Length > 1 ? BenchmarksCases.Select(benchmark => benchmark.GetRuntime()).Distinct().Count() > 1 : false;

internal static Summary NothingToRun(string title, string resultsDirectoryPath, string logFilePath)
=> new Summary(title, ImmutableArray<BenchmarkReport>.Empty, HostEnvironmentInfo.GetCurrent(), resultsDirectoryPath, logFilePath, TimeSpan.Zero, DefaultCultureInfo.Instance, ImmutableArray<ValidationError>.Empty);

Expand Down