private double GetGcValuesFromReport(GcStats gcStats, GcMetricSource metricSource) { switch (metricSource) { case GcMetricSource.BytesAllocatedPerOperation: return(gcStats.BytesAllocatedPerOperation); case GcMetricSource.BytesAllocatedPerOperationRaw: return(gcStats.GetTotalAllocatedBytes(false) * 1.0 / gcStats.TotalOperations); case GcMetricSource.Gen0CollectionsPer1000: return(1000.0 * gcStats.Gen0Collections / gcStats.TotalOperations); case GcMetricSource.Gen1CollectionsPer1000: return(1000.0 * gcStats.Gen1Collections / gcStats.TotalOperations); case GcMetricSource.Gen2CollectionsPer1000: return(1000.0 * gcStats.Gen2Collections / gcStats.TotalOperations); default: throw CodeExceptions.UnexpectedArgumentValue(nameof(metricSource), metricSource); } }
/// <summary>Initializes a new instance of the <see cref="TimeMetricValuesProvider"/> class.</summary> /// <param name="metricSource">Property of the <see cref="GcStats"/> to be used as a GC metric value.</param> /// <param name="resultIsRelative"><c>true</c> if the metric is relative.</param> public GcMetricValuesProvider(GcMetricSource metricSource, bool resultIsRelative) : base(SingleValueMetricCalculator.Instance, resultIsRelative) { EnumCode.Defined(metricSource, nameof(metricSource)); MetricSource = metricSource; }