Skip to content

Commit

Permalink
Update SurvivedMemoryMetricDescriptor legend.
Browse files Browse the repository at this point in the history
Add extra Measurement constructor to preserve old way.
Re-add MemoryDiagnoserAttribute paramterless constructor.
  • Loading branch information
timcassell committed Nov 30, 2020
1 parent 7647117 commit db259cd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/BenchmarkDotNet/Attributes/MemoryDiagnoserAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public class MemoryDiagnoserAttribute : Attribute, IConfigSource
{
public IConfig Config { get; }

public MemoryDiagnoserAttribute(bool includeSurvived = false)
public MemoryDiagnoserAttribute() : this(false) { }

public MemoryDiagnoserAttribute(bool includeSurvived)
{
Config = ManualConfig.CreateEmpty().AddDiagnoser(includeSurvived ? MemoryDiagnoser.WithSurvived : MemoryDiagnoser.Default);
}
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Diagnosers/MemoryDiagnoser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private class SurvivedMemoryMetricDescriptor : IMetricDescriptor

public string Id => "Survived Memory";
public string DisplayName => "Survived";
public string Legend => "Total application memory consumed after all operations, including Cleanups (managed only, inclusive, 1KB = 1024B)";
public string Legend => "Total memory survived after all operations (managed only, inclusive, 1KB = 1024B)";
public string NumberFormat => "N0";
public UnitType UnitType => UnitType.Size;
public string Unit => SizeUnit.B.Name;
Expand Down
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Engines/GcStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public override int GetHashCode()
hashCode = (hashCode * 397) ^ Gen2Collections;
hashCode = (hashCode * 397) ^ AllocatedBytes.GetHashCode();
hashCode = (hashCode * 397) ^ TotalOperations.GetHashCode();
hashCode = (hashCode * 397) ^ SurvivedBytes.GetHashCode();
return hashCode;
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/BenchmarkDotNet/Reports/Measurement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct Measurement : IComparable<Measurement>
private const string OpSymbol = "op";
private const string SBSymbol = "B";

private static Measurement Error() => new Measurement(-1, IterationMode.Unknown, IterationStage.Unknown, 0, 0, 0, 0);
private static Measurement Error() => new Measurement(-1, IterationMode.Unknown, IterationStage.Unknown, 0, 0, 0);

private static readonly int IterationInfoNameMaxWidth
= Enum.GetNames(typeof(IterationMode)).Max(text => text.Length) + Enum.GetNames(typeof(IterationStage)).Max(text => text.Length);
Expand Down Expand Up @@ -49,6 +49,18 @@ private static readonly int IterationInfoNameMaxWidth
/// </summary>
public long SurvivedBytes { get; }

/// <summary>
/// Creates an instance of <see cref="Measurement"/> struct.
/// </summary>
/// <param name="launchIndex"></param>
/// <param name="iterationMode"></param>
/// <param name="iterationStage"></param>
/// <param name="iterationIndex"></param>
/// <param name="operations">The number of operations performed.</param>
/// <param name="nanoseconds">The total number of nanoseconds it took to perform all operations.</param>
public Measurement(int launchIndex, IterationMode iterationMode, IterationStage iterationStage, int iterationIndex, long operations, double nanoseconds)
: this(launchIndex, iterationMode, iterationStage, iterationIndex, operations, nanoseconds, 0) { }

/// <summary>
/// Creates an instance of <see cref="Measurement"/> struct.
/// </summary>
Expand Down

0 comments on commit db259cd

Please sign in to comment.