public void Mean_WhenPassed8And9_Returns8Point5()
 {
     var underTest = new Histogram(new ExponentiallyDecayingReservoir());
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(8.5, underTest.Snapshot.Mean);
 }
 public void Max_WhenPassed8And9_Returns9()
 {
     var underTest = new Histogram(new ExponentiallyDecayingReservoir());
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(9, underTest.Snapshot.Max);
 }
 public void Count_WhenPassedTwoValues_Returns2()
 {
     var underTest = new Histogram(new ExponentiallyDecayingReservoir());
     underTest.Update(9);
     underTest.Update(8);
     Assert.AreEqual(2, underTest.Count);
 }
        public void ValidateMeanAndMedianDifferent()
        {
            var underTest = new Histogram(new ExponentiallyDecayingReservoir());
            underTest.Update(7);
            underTest.Update(8);
            underTest.Update(12);

            Assert.AreEqual(8, underTest.Snapshot.Median);
            Assert.AreNotEqual(8, underTest.Snapshot.Mean);
            
        }
        private void reportHistogram(long timestamp, MetricName name, Histogram histogram)
        {
            Snapshot snapshot = histogram.Snapshot;

            report(timestamp,
                   name,
                   "count,max,mean,min,stddev,p50,p75,p95,p98,p99,p999",
                   histogram.Count,
                   snapshot.Max,
                   snapshot.Mean,
                   snapshot.Min,
                   snapshot.StdDev,
                   snapshot.Median,
                   snapshot.Percentile75th,
                   snapshot.Percentile95th,
                   snapshot.Percentile98th,
                   snapshot.Percentile99th,
                   snapshot.Percentile999th);
        }
 private void reportHistogram(MetricName name, Histogram histogram, long timestamp)
 {
     Snapshot snapshot = histogram.Snapshot;
     graphite.Send(Prefix(name, "count"), format(histogram.Count), timestamp);
     graphite.Send(Prefix(name, "max"), format(snapshot.Max), timestamp);
     graphite.Send(Prefix(name, "mean"), format(snapshot.Mean), timestamp);
     graphite.Send(Prefix(name, "min"), format(snapshot.Min), timestamp);
     graphite.Send(Prefix(name, "stddev"), format(snapshot.StdDev), timestamp);
     graphite.Send(Prefix(name, "p50"), format(snapshot.Median), timestamp);
     graphite.Send(Prefix(name, "p75"), format(snapshot.Percentile75th), timestamp);
     graphite.Send(Prefix(name, "p95"), format(snapshot.Percentile95th), timestamp);
     graphite.Send(Prefix(name, "p98"), format(snapshot.Percentile98th), timestamp);
     graphite.Send(Prefix(name, "p99"), format(snapshot.Percentile99th), timestamp);
     graphite.Send(Prefix(name, "p999"), format(snapshot.Percentile999th), timestamp);
 }
 private void printHistogram(Histogram histogram)
 {
     output.WriteLine(string.Format("             count = {0}", histogram.Count));
     Snapshot snapshot = histogram.Snapshot;
     output.WriteLine(string.Format("               min = {0}", snapshot.Min));
     output.WriteLine(string.Format("               max = {0}", snapshot.Max));
     output.WriteLine(string.Format("              mean = {0}", snapshot.Mean));
     output.WriteLine(string.Format("            stddev = {0}", snapshot.StdDev));
     output.WriteLine(string.Format("            median = {0}", snapshot.Median));
     output.WriteLine(string.Format("              75%% <= {0}", snapshot.Percentile75th));
     output.WriteLine(string.Format("              95%% <= {0}", snapshot.Percentile95th));
     output.WriteLine(string.Format("              98%% <= {0}", snapshot.Percentile98th));
     output.WriteLine(string.Format("              99%% <= {0}", snapshot.Percentile99th));
     output.WriteLine(string.Format("            99.9%% <= {0}", snapshot.Percentile999th));
 }