public void TestHistogramSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Histogram, Histogram = new Dictionary <long, uint> { { 1, 1 }, { 2, 1 } }, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var doubleSample = new DataSample { Histogram = new Dictionary <long, uint> { { 1, 2 }, { 10, 2 } } }; for (int i = 0; i < 100; i++) { combiner.AddData(doubleSample); } var result = combiner.Data; Assert.AreEqual((uint)201, result.Histogram[1]); Assert.AreEqual((uint)1, result.Histogram[2]); Assert.AreEqual((uint)200, result.Histogram[10]); }
public void TestMinimumSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Minimum, MinValue = 100, SampleCount = 100, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var addMe = new DataSample { SampleCount = 1000, SampleType = DataSampleType.Minimum }; for (int i = 0; i < 200; i++) { addMe.MinValue = i; combiner.AddData(addMe); } Assert.AreEqual(0, combiner.Data.MinValue); Assert.AreEqual((ulong)200100, combiner.Data.SampleCount); }
public void TestAverageSampleCombinerDoesNotOverflow() { const int iterations = 10; var theSample = new DataSample { SampleType = DataSampleType.Average, Average = double.MaxValue, SampleCount = ulong.MaxValue / (iterations + 1), StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(theSample); for (int i = 0; i < iterations; i++) { combiner.AddData(theSample); } }
public void TestAverageSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Average, Average = 1.0, SampleCount = 100, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var addMe = new DataSample { Average = 1.0, SampleCount = 1000, SampleType = DataSampleType.Average }; for (int i = 0; i < 100; i++) { combiner.AddData(addMe); } Assert.AreEqual(1.0, combiner.Data.Average); Assert.IsTrue(combiner.Data.SampleCount > 100); }
public void TestHistogramSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Histogram, Histogram = new Dictionary<long, uint> {{1, 1}, {2, 1}}, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var doubleSample = new DataSample { Histogram = new Dictionary<long, uint> {{1, 2}, {10, 2}} }; for (int i = 0; i < 100; i++) { combiner.AddData(doubleSample); } var result = combiner.Data; Assert.AreEqual((uint)201, result.Histogram[1]); Assert.AreEqual((uint)1, result.Histogram[2]); Assert.AreEqual((uint)200, result.Histogram[10]); }
public void TestMinimumSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Minimum, MinValue = 100, SampleCount = 100, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var addMe = new DataSample { SampleCount = 1000, SampleType = DataSampleType.Minimum}; for (int i = 0; i < 200; i++) { addMe.MinValue = i; combiner.AddData(addMe); } Assert.AreEqual(0, combiner.Data.MinValue); Assert.AreEqual((ulong)200100, combiner.Data.SampleCount); }
public void TestAverageSampleCombinerDoesNotOverflow() { const int iterations = 10; var theSample = new DataSample { SampleType = DataSampleType.Average, Average = double.MaxValue, SampleCount = ulong.MaxValue / (iterations + 1), StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(theSample); for (int i = 0; i < iterations; i++) { combiner.AddData(theSample); } }
public void TestAverageSampleCombiner() { var initialSample = new DataSample { SampleType = DataSampleType.Average, Average = 1.0, SampleCount = 100, StartTime = this.start.ToMillisecondTimestamp(), EndTime = this.end.ToMillisecondTimestamp() }; var combiner = new SampleCombiner(initialSample); var addMe = new DataSample { Average = 1.0, SampleCount = 1000, SampleType = DataSampleType.Average}; for (int i = 0; i < 100; i++) { combiner.AddData(addMe); } Assert.AreEqual(1.0, combiner.Data.Average); Assert.IsTrue(combiner.Data.SampleCount > 100); }