Пример #1
0
 /// <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 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");
 }