using System; namespace TBF.BenchControl.Sequences { public class FloatStatistics { float first; float last; float min; float max; float sum; UInt32 count; public float First { get { return first; } } public float Last { get { return last; } } public float Min { get { return min; } } public float Max { get { return max; } } public float Average { get { if (Count > 0) return sum / (float)count; else return 0; } } public UInt32 Count { get { return count; } } public FloatStatistics() { Clear(); } /// /// Resets statistics /// public void Clear() { sum = 0; min = float.MaxValue; max = float.MinValue; first = 0; last = 0; count = 0; } /// /// Updates statistics /// /// New value public void Update(float value) { if (count == 0) first = value; last = value; sum += value; if (value < min) min = value; if (value > max) max = value; count++; } /// /// Updates statistics /// /// New boxed value public void Update(TBF.Boxes.FloatBox box) { Update(box.Val); } } }