private void AssertValues(IReservoirSnapshot snapshot) { snapshot.Count.Should().Be(4); snapshot.Max.Should().Be(5); if (snapshot is WeightedSnapshot) { snapshot.Mean.Should().BeApproximately(2.5, 1); snapshot.Median.Should().Be(4.0); snapshot.Percentile75.Should().Be(5.0); } else { snapshot.Mean.Should().BeApproximately(2.5, 1.0); snapshot.Percentile75.Should().BeApproximately(4.75, 2.0); snapshot.Median.Should().BeApproximately(2.5, 1.0); } snapshot.Min.Should().Be(0); snapshot.Percentile95.Should().BeApproximately(5.0, 1); snapshot.Percentile98.Should().BeApproximately(5.0, 1); snapshot.Percentile99.Should().BeApproximately(5.0, 1); snapshot.Percentile999.Should().BeApproximately(5.0, 1); snapshot.Size.Should().Be(4); snapshot.StdDev.Should().BeApproximately(2.3, 1); }
private void UnsafeRefresh(long nowTicks, bool empty) { // don't recycle the current histogram as it is being used by the cached snapshot _intervalHistogram = _recorder.GetIntervalHistogram(); Interlocked.Exchange(ref _lastRefreshTicks, nowTicks); _cachedSnapshot = BuildSnapshot(empty); }
static HdrHistogramReservoir() { HdrHistogramReservoir._emptySnapshot = new HdrSnapshot( HistogramFactory .With64BitBucketSize() .WithThreadSafeReads() .Create() .GetIntervalHistogram(), 0, null, 0, null); }
private void AssertSecondSnapshot(IReservoirSnapshot snapshot) { Assert.AreEqual(299d, snapshot.Percentile99); Assert.AreEqual(275d, snapshot.Percentile75); Assert.AreEqual(298d, snapshot.Percentile98); Assert.AreEqual(300d, snapshot.Percentile999); Assert.AreEqual(295d, snapshot.Percentile95); Assert.AreEqual(300d, snapshot.Max); Assert.AreEqual(201d, snapshot.Min); Assert.AreEqual(250.5d, snapshot.Mean); Assert.AreEqual(250d, snapshot.Median); Assert.AreEqual(100d, snapshot.Count); }
private void AssertFirstSnapshot(IReservoirSnapshot snapshot) { Assert.AreEqual(99d, snapshot.Percentile99); Assert.AreEqual(75d, snapshot.Percentile75); Assert.AreEqual(98d, snapshot.Percentile98); Assert.AreEqual(100d, snapshot.Percentile999); Assert.AreEqual(95d, snapshot.Percentile95); Assert.AreEqual(100d, snapshot.Max); Assert.AreEqual(1d, snapshot.Min); Assert.AreEqual(50.5d, snapshot.Mean); Assert.AreEqual(50d, snapshot.Median); Assert.AreEqual(100d, snapshot.Count); }
private void AssertEmptySnapshot(IReservoirSnapshot snapshot) { Assert.AreEqual(0d, snapshot.Percentile99); Assert.AreEqual(0d, snapshot.Percentile75); Assert.AreEqual(0d, snapshot.Percentile98); Assert.AreEqual(0d, snapshot.Percentile999); Assert.AreEqual(0d, snapshot.Percentile95); Assert.AreEqual(0d, snapshot.Max); Assert.AreEqual(0d, snapshot.Min); Assert.AreEqual(0d, snapshot.Mean); Assert.AreEqual(0d, snapshot.Median); Assert.AreEqual(0d, snapshot.Count); }
public HistogramValue(double lastValue, string lastUserValue, IReservoirSnapshot snapshot) : this( snapshot.Count, lastValue, lastUserValue, snapshot.Max, snapshot.MaxUserValue, snapshot.Mean, snapshot.Min, snapshot.MinUserValue, snapshot.StdDev, snapshot.Median, snapshot.Percentile75, snapshot.Percentile95, snapshot.Percentile98, snapshot.Percentile99, snapshot.Percentile999, snapshot.Size) { }
public void weight_snapshot_calculates_the_standard_deviation_of_zero_for_an_empty_snapshot() { IReservoirSnapshot snapshot = MakeSanpshot(new long[0], new double[0]); snapshot.StdDev.Should().Be(0); }
public void weight_snapshot_calculates_the_min_of_zero_for_an_empty_snapshot() { IReservoirSnapshot snapshot = MakeSanpshot(new long[0], new double[0]); snapshot.Min.Should().Be(0); }