暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SampleUnit.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. namespace Unity.PerformanceTesting
  3. {
  4. /// <summary>
  5. /// Measurement unit used for sample groups.
  6. /// </summary>
  7. public enum SampleUnit
  8. {
  9. /// <summary>
  10. /// Nanoseconds.
  11. /// </summary>
  12. Nanosecond,
  13. /// <summary>
  14. /// Microseconds.
  15. /// </summary>
  16. Microsecond,
  17. /// <summary>
  18. /// Milliseconds.
  19. /// </summary>
  20. Millisecond,
  21. /// <summary>
  22. /// Seconds.
  23. /// </summary>
  24. Second,
  25. /// <summary>
  26. /// Bytes.
  27. /// </summary>
  28. Byte,
  29. /// <summary>
  30. /// Kilobytes.
  31. /// </summary>
  32. Kilobyte,
  33. /// <summary>
  34. /// Megabytes.
  35. /// </summary>
  36. Megabyte,
  37. /// <summary>
  38. /// Gigabytes.
  39. /// </summary>
  40. Gigabyte,
  41. /// <summary>
  42. /// Undefined, represents any other unit we don't have by default. When using it make sure your sample group name represents the measurement.
  43. /// </summary>
  44. Undefined
  45. }
  46. static class SampleUnitExtensions
  47. {
  48. public static string ShortName(this SampleUnit s)
  49. {
  50. switch (s)
  51. {
  52. case SampleUnit.Nanosecond:
  53. return "ns";
  54. case SampleUnit.Microsecond:
  55. return "μs";
  56. case SampleUnit.Millisecond:
  57. return "ms";
  58. case SampleUnit.Second:
  59. return "s";
  60. case SampleUnit.Byte:
  61. return "b";
  62. case SampleUnit.Kilobyte:
  63. return "kb";
  64. case SampleUnit.Megabyte:
  65. return "mb";
  66. case SampleUnit.Gigabyte:
  67. return "gb";
  68. case SampleUnit.Undefined:
  69. return "";
  70. default:
  71. throw new ArgumentOutOfRangeException(nameof(s), s, null);
  72. }
  73. }
  74. }
  75. }