-
-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move literals into a class; In future it will be used for cli code completion; StatisticalTest/HardwareCounters/CiLower are missing * Add HideColumns * Do not start printing a table when no columns, Replace it with the message * Show legends only for visible columns i.e. hide the time legend when Mean&Error are hidden * Replace AllocRatio ctor creation to the static field, like BaselineRatioColumn.RatioMean * Encapsulate tight logic in SummaryTableColumn * Add CLI support * Print common columns when all columns are hidden * solve warnings and errors * improvements: - don't store Names in the field when there is no need to - make it possible to apply `[HideColumnsAttribute]` to entire assembly - add comment explaining why Column class is public - make two existing column hiding rules public so they can be reused - Column.IsCommon is better name than Column.IsCommonColumn - simplify LINQ -add sample Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
- Loading branch information
1 parent
8380003
commit 8ec00dd
Showing
43 changed files
with
375 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Columns; | ||
|
||
namespace BenchmarkDotNet.Samples | ||
{ | ||
[MemoryDiagnoser] // adds Gen0, Gen1, Gen2 and Allocated Bytes columns | ||
[HideColumns(Column.Gen0, Column.Gen1, Column.Gen2)] // dont display GenX columns | ||
public class IntroHidingColumns | ||
{ | ||
[Benchmark] | ||
public byte[] AllocateArray() => new byte[100_000]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using BenchmarkDotNet.Extensions; | ||
using BenchmarkDotNet.Reports; | ||
|
||
namespace BenchmarkDotNet.Analysers | ||
{ | ||
public class HideColumnsAnalyser : AnalyserBase | ||
{ | ||
public static readonly IAnalyser Default = new HideColumnsAnalyser(); | ||
|
||
public override string Id => nameof(HideColumnsAnalyser); | ||
|
||
protected override IEnumerable<Conclusion> AnalyseSummary(Summary summary) | ||
{ | ||
var hiddenColumns = summary.GetTable(summary.Style).Columns.Where(c => c.WasHidden).ToArray(); | ||
|
||
if (hiddenColumns.IsEmpty()) | ||
yield break; | ||
|
||
var columnNames = string.Join(", ", hiddenColumns.Select(c => c.OriginalColumn.ColumnName)); | ||
|
||
var message = $"Hidden columns: {columnNames}"; | ||
yield return Conclusion.CreateHint(Id, message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using BenchmarkDotNet.Configs; | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Attributes | ||
{ | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] | ||
public class HideColumnsAttribute : Attribute, IConfigSource | ||
{ | ||
public IConfig Config { get; } | ||
|
||
// CLS-Compliant Code requires a constructor without an array in the argument list | ||
protected HideColumnsAttribute() => Config = ManualConfig.CreateEmpty(); | ||
|
||
public HideColumnsAttribute(params string[] names) => Config = ManualConfig.CreateEmpty().HideColumns(names); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Columns | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
[PublicAPI] // this type is public, so the users can do things like [HideColumns(Column.$)] and get suggestions from IDE | ||
public static class Column | ||
{ | ||
public const string Namespace = "Namespace"; | ||
public const string Type = "Type"; | ||
public const string Method = "Method"; | ||
|
||
public const string Job = "Job"; | ||
|
||
public const string Mean = "Mean"; | ||
public const string StdErr = "StdErr"; | ||
public const string StdDev = "StdDev"; | ||
public const string Error = "Error"; | ||
public const string OperationPerSecond = "Op/s"; | ||
public const string Min = "Min"; | ||
public const string Q1 = "Q1"; | ||
public const string Median = "Median"; | ||
public const string Q3 = "Q3"; | ||
public const string Max = "Max"; | ||
public const string Skewness = "Skewness"; | ||
public const string Kurtosis = "Kurtosis"; | ||
public const string MValue = "MValue"; | ||
public const string Iterations = "Iterations"; | ||
|
||
public const string P0 = "P0"; | ||
public const string P25 = "P25"; | ||
public const string P50 = "P50"; | ||
public const string P67 = "P67"; | ||
public const string P80 = "P80"; | ||
public const string P85 = "P85"; | ||
public const string P90 = "P90"; | ||
public const string P95 = "P95"; | ||
public const string P100 = "P100"; | ||
|
||
public const string Categories = "Categories"; | ||
public const string LogicalGroup = "LogicalGroup"; | ||
public const string Rank = "Rank"; | ||
|
||
public const string Ratio = "Ratio"; | ||
public const string RatioSD = "RatioSD"; | ||
public const string AllocRatio = "Alloc Ratio"; | ||
|
||
public const string Allocated = "Allocated"; | ||
public const string Gen0 = "Gen0"; | ||
public const string Gen1 = "Gen1"; | ||
public const string Gen2 = "Gen2"; | ||
|
||
public const string AllocatedNativeMemory = "Allocated native memory"; | ||
public const string NativeMemoryLeak = "Native memory leak"; | ||
public const string CompletedWorkItems = "Completed Work Items"; | ||
public const string LockContentions = "Lock Contentions"; | ||
public const string CodeSize = "Code Size"; | ||
|
||
//Characteristics: | ||
public const string Id = "Id"; | ||
|
||
public const string MaxRelativeError = "MaxRelativeError"; | ||
public const string MaxAbsoluteError = "MaxAbsoluteError"; | ||
public const string MinIterationTime = "MinIterationTime"; | ||
public const string MinInvokeCount = "MinInvokeCount"; | ||
public const string EvaluateOverhead = "EvaluateOverhead"; | ||
public const string OutlierMode = "OutlierMode"; | ||
public const string AnalyzeLaunchVariance = "AnalyzeLaunchVariance"; | ||
|
||
public const string Platform = "Platform"; | ||
public const string Jit = "Jit"; | ||
public const string Runtime = "Runtime"; | ||
public const string Affinity = "Affinity"; | ||
public const string Gc = "Gc"; | ||
public const string EnvironmentVariables = "EnvironmentVariables"; | ||
public const string PowerPlanMode = "PowerPlanMode"; | ||
|
||
public const string Server = "Server"; | ||
public const string Concurrent = "Concurrent"; | ||
public const string CpuGroups = "CpuGroups"; | ||
public const string Force = "Force"; | ||
public const string AllowVeryLargeObjects = "AllowVeryLargeObjects"; | ||
public const string RetainVm = "RetainVm"; | ||
public const string NoAffinitize = "NoAffinitize"; | ||
public const string HeapAffinitizeMask = "HeapAffinitizeMask"; | ||
public const string HeapCount = "HeapCount"; | ||
|
||
public const string Toolchain = "Toolchain"; | ||
public const string Clock = "Clock"; | ||
public const string EngineFactory = "EngineFactory"; | ||
public const string BuildConfiguration = "BuildConfiguration"; | ||
public const string Arguments = "Arguments"; | ||
public const string NuGetReferences = "NuGetReferences"; | ||
|
||
public const string Environment = "Environment"; | ||
public const string Run = "Run"; | ||
public const string Infrastructure = "Infrastructure"; | ||
public const string Accuracy = "Accuracy"; | ||
public const string Meta = "Meta"; | ||
|
||
public const string Baseline = "Baseline"; | ||
public const string IsMutator = "IsMutator"; | ||
public const string IsDefault = "IsDefault"; | ||
|
||
public const string RunStrategy = "RunStrategy"; | ||
public const string LaunchCount = "LaunchCount"; | ||
public const string InvocationCount = "InvocationCount"; | ||
public const string UnrollFactor = "UnrollFactor"; | ||
public const string IterationCount = "IterationCount"; | ||
public const string MinIterationCount = "MinIterationCount"; | ||
public const string MaxIterationCount = "MaxIterationCount"; | ||
public const string IterationTime = "IterationTime"; | ||
public const string WarmupCount = "WarmupCount"; | ||
public const string MinWarmupIterationCount = "MinWarmupIterationCount"; | ||
public const string MaxWarmupIterationCount = "MaxWarmupIterationCount"; | ||
public const string MemoryRandomization = "MemoryRandomization"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Columns | ||
{ | ||
[PublicAPI] | ||
public class ColumnHidingByIdRule: IColumnHidingRule | ||
{ | ||
public string Id { get; } | ||
|
||
public ColumnHidingByIdRule(IColumn column) => Id = column.Id; | ||
|
||
public bool NeedToHide(IColumn column) => column.Id == Id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Columns | ||
{ | ||
[PublicAPI] | ||
public class ColumnHidingByNameRule: IColumnHidingRule | ||
{ | ||
public string Name { get; } | ||
|
||
public ColumnHidingByNameRule(string name) => Name = name; | ||
|
||
public bool NeedToHide(IColumn column) => column.ColumnName == Name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace BenchmarkDotNet.Columns | ||
{ | ||
public interface IColumnHidingRule | ||
{ | ||
bool NeedToHide(IColumn column); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.