using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Unity.PerformanceTesting.Exceptions;
namespace Unity.PerformanceTesting.Data
{
///
/// Represents a group of samples for a performance test that share a common name and unit.
///
[Serializable]
public class SampleGroup : IDeserializationCallback
{
///
/// Name of the sample group.
///
public string Name;
///
/// Measurement unit.
///
public SampleUnit Unit;
///
/// Whether the measurement is inverted and increase is positive.
///
public bool IncreaseIsBetter;
///
/// List of samples.
///
public List Samples = new List();
///
/// Minimum value of samples.
///
public double Min;
///
/// Maximum value of samples.
///
public double Max;
///
/// Median value of samples.
///
public double Median;
///
/// Average value of samples.
///
public double Average;
///
/// Standard deviation of samples.
///
public double StandardDeviation;
///
/// Sum of samples.
///
public double Sum;
///
/// Creates a sample group without initializing values.
///
public SampleGroup(){}
///
/// Creates a sample group with provided arguments.
///
/// Sample group name.
/// Measurement unit.
/// Whether the measurement is inverted and increase is positive.
/// Exception thrown when invalid name is used.
public SampleGroup(string name, SampleUnit unit, bool increaseIsBetter)
{
Name = name;
Unit = unit;
IncreaseIsBetter = increaseIsBetter;
if (string.IsNullOrEmpty(name))
{
throw new PerformanceTestException("Sample group name is empty. Please assign a valid name.");
}
}
///
/// Validates the deserialized object.
///
/// The object that initiated the deserialization process.
public void OnDeserialization(object sender)
{
if (string.IsNullOrEmpty(Name))
{
throw new PerformanceTestException("Sample group name is empty. Please assign a valid name.");
}
}
}
}