InputMetrics.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. ////TODO: provide total metric for amount of unmanaged memory (device state + action state)
  3. namespace UnityEngine.InputSystem.LowLevel
  4. {
  5. /// <summary>
  6. /// Provides information on the level of throughput going through the system.
  7. /// </summary>
  8. /// <seealso cref="InputSystem.metrics"/>
  9. [Serializable]
  10. public struct InputMetrics
  11. {
  12. /// <summary>
  13. /// Maximum number of devices that were concurrently added to the system.
  14. /// </summary>
  15. /// <seealso cref="InputSystem.devices"/>
  16. public int maxNumDevices { get; set; }
  17. /// <summary>
  18. /// Number of devices currently added to the system.
  19. /// </summary>
  20. /// <seealso cref="InputSystem.devices"/>
  21. public int currentNumDevices { get; set; }
  22. /// <summary>
  23. /// The largest the combined state memory for all devices got.
  24. /// </summary>
  25. public int maxStateSizeInBytes { get; set; }
  26. /// <summary>
  27. /// Total size of the combined state memory for all current devices.
  28. /// </summary>
  29. public int currentStateSizeInBytes { get; set; }
  30. /// <summary>
  31. /// Total number of <see cref="InputControl"/>s currently alive in
  32. /// devices in the system.
  33. /// </summary>
  34. public int currentControlCount { get; set; }
  35. /// <summary>
  36. /// Total number of currently registered layouts.
  37. /// </summary>
  38. public int currentLayoutCount { get; set; }
  39. /// <summary>
  40. /// Total number of bytes of <see cref="InputEvent"/>s consumed so far.
  41. /// </summary>
  42. public int totalEventBytes { get; set; }
  43. /// <summary>
  44. /// Total number of <see cref="InputEvent"/>s consumed so far.
  45. /// </summary>
  46. public int totalEventCount { get; set; }
  47. /// <summary>
  48. /// Total number of input system updates run so far.
  49. /// </summary>
  50. /// <seealso cref="InputSystem.Update"/>
  51. public int totalUpdateCount { get; set; }
  52. /// <summary>
  53. /// Total time in seconds spent processing <see cref="InputEvent"/>s so far.
  54. /// </summary>
  55. /// <remarks>
  56. /// Event processing usually amounts for the majority of time spent in <see cref="InputSystem.Update"/>
  57. /// but not necessarily for all of it.
  58. /// </remarks>
  59. /// <seealso cref="InputSystem.Update"/>
  60. public double totalEventProcessingTime { get; set; }
  61. /// <summary>
  62. /// Total accumulated time that has passed between when events were generated (see <see cref="InputEvent.time"/>)
  63. /// compared to when they were processed.
  64. /// </summary>
  65. public double totalEventLagTime { get; set; }
  66. /// <summary>
  67. /// Average size of the event buffer received on every <see cref="InputSystem.Update"/>.
  68. /// </summary>
  69. public float averageEventBytesPerFrame => (float)totalEventBytes / totalUpdateCount;
  70. ////REVIEW: we probably want better averaging than we get with this method; ideally, we should take averages
  71. //// each frame and then compute weighted averages as we go; the current method disregards updating spacing
  72. //// and event clustering entirely
  73. /// <summary>
  74. /// Average time in seconds spend on processing each individual <see cref="InputEvent"/>.
  75. /// </summary>
  76. public double averageProcessingTimePerEvent => totalEventProcessingTime / totalEventCount;
  77. /// <summary>
  78. /// Average time it takes from when an event is generated to when it is processed.
  79. /// </summary>
  80. /// <seealso cref="totalEventLagTime"/>
  81. public double averageLagTimePerEvent => totalEventLagTime / totalEventCount;
  82. }
  83. }