using System; namespace Unity.PerformanceTesting { /// /// Measurement unit used for sample groups. /// public enum SampleUnit { /// /// Nanoseconds. /// Nanosecond, /// /// Microseconds. /// Microsecond, /// /// Milliseconds. /// Millisecond, /// /// Seconds. /// Second, /// /// Bytes. /// Byte, /// /// Kilobytes. /// Kilobyte, /// /// Megabytes. /// Megabyte, /// /// Gigabytes. /// Gigabyte, /// /// Undefined, represents any other unit we don't have by default. When using it make sure your sample group name represents the measurement. /// Undefined } static class SampleUnitExtensions { public static string ShortName(this SampleUnit s) { switch (s) { case SampleUnit.Nanosecond: return "ns"; case SampleUnit.Microsecond: return "μs"; case SampleUnit.Millisecond: return "ms"; case SampleUnit.Second: return "s"; case SampleUnit.Byte: return "b"; case SampleUnit.Kilobyte: return "kb"; case SampleUnit.Megabyte: return "mb"; case SampleUnit.Gigabyte: return "gb"; case SampleUnit.Undefined: return ""; default: throw new ArgumentOutOfRangeException(nameof(s), s, null); } } } }