public void CanReadv1Logs_Skip_PreStart(string logPath, int skip, int take, int expectedHistogramCount, int expectedCombinedValueCount, int expectedCombined999, long expectedCombinedMaxLength, double expectedStartTime) { var readerStream = GetEmbeddedFileStream(logPath); var reader = new HistogramLogReader(readerStream); int histogramCount = 0; long totalCount = 0; HistogramBase accumulatedHistogram = Create(OneHourOfNanoseconds, DefaultSignificantDigits); var histograms = reader.ReadHistograms() .Where(h => h.StartTimeStamp >= reader.GetStartTime().MillisecondsSinceUnixEpoch()) .Skip(skip) .Take(take); foreach (var histogram in histograms) { histogramCount++; totalCount += histogram.TotalCount; accumulatedHistogram.Add(histogram); } Assert.Equal(expectedHistogramCount, histogramCount); Assert.Equal(expectedCombinedValueCount, totalCount); Assert.Equal(expectedCombined999, accumulatedHistogram.GetValueAtPercentile(99.9)); Assert.Equal(expectedCombinedMaxLength, accumulatedHistogram.GetMaxValue()); Assert.Equal(expectedStartTime, reader.GetStartTime().SecondsSinceUnixEpoch()); }
/// <summary> /// Initializes a new instance of the <see cref="HdrSnapshot" /> class. /// </summary> /// <param name="histogram">The histogram.</param> /// <param name="minValue">The minimum value.</param> /// <param name="minUserValue">The minimum user value.</param> /// <param name="maxValue">The maximum value.</param> /// <param name="maxUserValue">The maximum user value.</param> public HdrSnapshot(HistogramBase histogram, long minValue, string minUserValue, long maxValue, string maxUserValue) { _histogram = histogram; Min = !string.IsNullOrWhiteSpace(minUserValue) ? minValue : histogram.HighestEquivalentValue(histogram.RecordedValues().Select(hiv => hiv.ValueIteratedTo).FirstOrDefault()); MinUserValue = minUserValue; Max = !string.IsNullOrWhiteSpace(maxUserValue) ? maxValue : _histogram.GetMaxValue(); MaxUserValue = maxUserValue; }
public void WriteFooter(HistogramBase histogram) { // Calculate and output mean and std. deviation. // Note: mean/std. deviation numbers are very often completely irrelevant when // data is extremely non-normal in distribution (e.g. in cases of strong multi-modal // response time distribution associated with GC pauses). However, reporting these numbers // can be very useful for contrasting with the detailed percentile distribution // reported by outputPercentileDistribution(). It is not at all surprising to find // percentile distributions where results fall many tens or even hundreds of standard // deviations away from the mean - such results simply indicate that the data sampled // exhibits a very non-normal distribution, highlighting situations for which the std. // deviation metric is a useless indicator. var mean = histogram.GetMean() / _outputValueUnitScalingRatio; var stdDeviation = histogram.GetStdDeviation() / _outputValueUnitScalingRatio; _printStream.Write(_footerLine1FormatString, mean, stdDeviation); _printStream.Write(_footerLine2FormatString, histogram.GetMaxValue() / _outputValueUnitScalingRatio, histogram.TotalCount); _printStream.Write(_footerLine3FormatString, histogram.BucketCount, histogram.SubBucketCount); }
public void WriteFooter(HistogramBase histogram) { // Calculate and output mean and std. deviation. // Note: mean/std. deviation numbers are very often completely irrelevant when // data is extremely non-normal in distribution (e.g. in cases of strong multi-modal // response time distribution associated with GC pauses). However, reporting these numbers // can be very useful for contrasting with the detailed percentile distribution // reported by outputPercentileDistribution(). It is not at all surprising to find // percentile distributions where results fall many tens or even hundreds of standard // deviations away from the mean - such results simply indicate that the data sampled // exhibits a very non-normal distribution, highlighting situations for which the std. // deviation metric is a useless indicator. var mean = histogram.GetMean() / _outputValueUnitScalingRatio; var stdDeviation = histogram.GetStdDeviation() / _outputValueUnitScalingRatio; _printStream.Write(_footerLine1FormatString, mean, stdDeviation); _printStream.Write(_footerLine2FormatString, histogram.GetMaxValue() / _outputValueUnitScalingRatio, histogram.TotalCount); _printStream.Write(_footerLine3FormatString, histogram.BucketCount, histogram.SubBucketCount); }
public void TestScalingEquivalence() { Assert.AreEqual( LongHistogram.GetMean() * 512, ScaledHistogram.GetMean(), ScaledHistogram.GetMean() * 0.000001, "averages should be equivalent"); Assert.AreEqual( LongHistogram.TotalCount, ScaledHistogram.TotalCount, "total count should be the same"); Assert.AreEqual( LongHistogram.LowestEquivalentValue(LongHistogram.GetValueAtPercentile(99.0)) * 512, ScaledHistogram.LowestEquivalentValue(ScaledHistogram.GetValueAtPercentile(99.0)), "99%'iles should be equivalent"); Assert.AreEqual( ScaledHistogram.HighestEquivalentValue(LongHistogram.GetMaxValue() * 512), ScaledHistogram.GetMaxValue(), "Max should be equivalent for scaled data"); // Same for post-corrected: Assert.AreEqual( LongHistogram.GetMean() * 512, ScaledHistogram.GetMean(), ScaledHistogram.GetMean() * 0.000001, "averages should be equivalent"); Assert.AreEqual( PostCorrectedHistogram.TotalCount, PostCorrectedScaledHistogram.TotalCount, "total count should be the same"); Assert.AreEqual( PostCorrectedHistogram.LowestEquivalentValue(PostCorrectedHistogram.GetValueAtPercentile(99.0)) * 512, PostCorrectedScaledHistogram.LowestEquivalentValue(PostCorrectedScaledHistogram.GetValueAtPercentile(99.0)), "99%'iles should be equivalent"); Assert.AreEqual( PostCorrectedScaledHistogram.HighestEquivalentValue(PostCorrectedHistogram.GetMaxValue() * 512), PostCorrectedScaledHistogram.GetMaxValue(), "Max should be equivalent for post-corrected data"); }