private static void ProcessHistogrmaResults(LongHistogram histogram) { Console.WriteLine(); var percentiles = new[] { 50.0, 90.0, 95.0, 99.9, 99.99, 99.999, 99.9999, 99.99999, 99.999999, 100.0 }; foreach (var percentile in percentiles) { var value = histogram.GetValueAtPercentile(percentile) / OutputScalingFactor.TimeStampToMilliseconds; Console.WriteLine($"{percentile,10:##.######}th Percentile : {value,9:N4} ms"); } Console.WriteLine( $" Max : {histogram.GetMaxValue() / OutputScalingFactor.TimeStampToMilliseconds,9:N4} ms"); var fileName = "HistogramResults.hgrm"; if (File.Exists(fileName)) { File.Delete(fileName); } using (var writer = new StreamWriter(fileName)) { histogram.OutputPercentileDistribution(writer, outputValueUnitScalingRatio: OutputScalingFactor.TimeStampToMilliseconds); } }
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 = new LongHistogram(3600L * 1000 * 1000 * 1000, 3); 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.AreEqual(expectedHistogramCount, histogramCount); Assert.AreEqual(expectedCombinedValueCount, totalCount); Assert.AreEqual(expectedCombined999, accumulatedHistogram.GetValueAtPercentile(99.9)); Assert.AreEqual(expectedCombinedMaxLength, accumulatedHistogram.GetMaxValue()); Assert.AreEqual(expectedStartTime, reader.GetStartTime().SecondsSinceUnixEpoch()); }
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"); }
public void CanReadv2Logs(string logPath) { var readerStream = GetEmbeddedFileStream(logPath); var reader = new HistogramLogReader(readerStream); int histogramCount = 0; long totalCount = 0; var accumulatedHistogram = new LongHistogram(85899345920838, 3); foreach (var histogram in reader.ReadHistograms()) { histogramCount++; Assert.IsInstanceOf <HistogramBase>(histogram, "Expected integer value histograms in log file"); totalCount += histogram.TotalCount; accumulatedHistogram.Add(histogram); } Assert.AreEqual(62, histogramCount); Assert.AreEqual(48761, totalCount); Assert.AreEqual(1745879039, accumulatedHistogram.GetValueAtPercentile(99.9)); Assert.AreEqual(1796210687, accumulatedHistogram.GetMaxValue()); Assert.AreEqual(1441812279.474, reader.GetStartTime().SecondsSinceUnixEpoch()); }
public void CanReadv2Logs(string logPath) { var readerStream = GetEmbeddedFileStream(logPath); var reader = new HistogramLogReader(readerStream); int histogramCount = 0; long totalCount = 0; var accumulatedHistogram = new LongHistogram(85899345920838, 3); foreach (var histogram in reader.ReadHistograms()) { histogramCount++; Assert.IsInstanceOf<HistogramBase>(histogram, "Expected integer value histograms in log file"); totalCount += histogram.TotalCount; accumulatedHistogram.Add(histogram); } Assert.AreEqual(62, histogramCount); Assert.AreEqual(48761, totalCount); Assert.AreEqual(1745879039, accumulatedHistogram.GetValueAtPercentile(99.9)); Assert.AreEqual(1796210687, accumulatedHistogram.GetMaxValue()); Assert.AreEqual(1441812279.474, reader.GetStartTime().SecondsSinceUnixEpoch()); }