using System;
namespace Unity.Cloud.UserReporting
{
///
/// Represents a user report metrics.
///
public struct UserReportMetric
{
#region Properties
///
/// Gets the average.
///
public double Average
{
get { return this.Sum / this.Count; }
}
///
/// Gets the count.
///
public int Count { get; set; }
///
/// Gets the maximum.
///
public double Maximum { get; set; }
///
/// Gets the minimum.
///
public double Minimum { get; set; }
///
/// Gets the name.
///
public string Name { get; set; }
///
/// Gets the sum.
///
public double Sum { get; set; }
#endregion
#region Methods
///
/// Samples a value.
///
/// The value.
public void Sample(double value)
{
if (this.Count == 0)
{
this.Minimum = double.MaxValue;
this.Maximum = double.MinValue;
}
this.Count++;
this.Sum += value;
this.Minimum = Math.Min(this.Minimum, value);
this.Maximum = Math.Max(this.Maximum, value);
}
#endregion
}
}