PerformanceCounter.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Diagnostics;
  2. namespace Ryujinx.Common
  3. {
  4. public static class PerformanceCounter
  5. {
  6. /// <summary>
  7. /// Represents the number of ticks in 1 day.
  8. /// </summary>
  9. public static long TicksPerDay { get; }
  10. /// <summary>
  11. /// Represents the number of ticks in 1 hour.
  12. /// </summary>
  13. public static long TicksPerHour { get; }
  14. /// <summary>
  15. /// Represents the number of ticks in 1 minute.
  16. /// </summary>
  17. public static long TicksPerMinute { get; }
  18. /// <summary>
  19. /// Represents the number of ticks in 1 second.
  20. /// </summary>
  21. public static long TicksPerSecond { get; }
  22. /// <summary>
  23. /// Represents the number of ticks in 1 millisecond.
  24. /// </summary>
  25. public static long TicksPerMillisecond { get; }
  26. /// <summary>
  27. /// Gets the number of milliseconds elapsed since the system started.
  28. /// </summary>
  29. public static long ElapsedTicks
  30. {
  31. get
  32. {
  33. return Stopwatch.GetTimestamp();
  34. }
  35. }
  36. /// <summary>
  37. /// Gets the number of milliseconds elapsed since the system started.
  38. /// </summary>
  39. public static long ElapsedMilliseconds
  40. {
  41. get
  42. {
  43. long timestamp = Stopwatch.GetTimestamp();
  44. return timestamp / TicksPerMillisecond;
  45. }
  46. }
  47. static PerformanceCounter()
  48. {
  49. TicksPerMillisecond = Stopwatch.Frequency / 1000;
  50. TicksPerSecond = Stopwatch.Frequency;
  51. TicksPerMinute = TicksPerSecond * 60;
  52. TicksPerHour = TicksPerMinute * 60;
  53. TicksPerDay = TicksPerHour * 24;
  54. }
  55. }
  56. }