using System;
namespace TBF.BenchControl.Sequences
{
public class Statistics
{
double first;
double last;
double min;
double max;
double sum;
UInt32 count;
public float First { get { return (float)first; } }
public float Last { get { return (float)last; } }
public float Min { get { return (float)min; } }
public float Max { get { return (float)max; } }
public float Average { get { if (Count > 0) return (float)(sum / (double)count); else return 0; } }
public UInt32 Count { get { return count; } }
public double Sum { get { return sum; } }
public Statistics()
{
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(double 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.DoubleBox box)
{
Update(box.Val);
}
///
/// Updates statistics
///
/// New boxed value
public void Update(TBF.Boxes.FloatBox box)
{
Update(box.Val);
}
}
}