aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/PerformanceCounter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Common/PerformanceCounter.cs')
-rw-r--r--Ryujinx.Common/PerformanceCounter.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/Ryujinx.Common/PerformanceCounter.cs b/Ryujinx.Common/PerformanceCounter.cs
new file mode 100644
index 00000000..4c8ae6a7
--- /dev/null
+++ b/Ryujinx.Common/PerformanceCounter.cs
@@ -0,0 +1,65 @@
+using System.Diagnostics;
+
+namespace Ryujinx.Common
+{
+ public static class PerformanceCounter
+ {
+ /// <summary>
+ /// Represents the number of ticks in 1 day.
+ /// </summary>
+ public static long TicksPerDay { get; }
+
+ /// <summary>
+ /// Represents the number of ticks in 1 hour.
+ /// </summary>
+ public static long TicksPerHour { get; }
+
+ /// <summary>
+ /// Represents the number of ticks in 1 minute.
+ /// </summary>
+ public static long TicksPerMinute { get; }
+
+ /// <summary>
+ /// Represents the number of ticks in 1 second.
+ /// </summary>
+ public static long TicksPerSecond { get; }
+
+ /// <summary>
+ /// Represents the number of ticks in 1 millisecond.
+ /// </summary>
+ public static long TicksPerMillisecond { get; }
+
+ /// <summary>
+ /// Gets the number of milliseconds elapsed since the system started.
+ /// </summary>
+ public static long ElapsedTicks
+ {
+ get
+ {
+ return Stopwatch.GetTimestamp();
+ }
+ }
+
+ /// <summary>
+ /// Gets the number of milliseconds elapsed since the system started.
+ /// </summary>
+ public static long ElapsedMilliseconds
+ {
+ get
+ {
+ long timestamp = Stopwatch.GetTimestamp();
+
+ return timestamp / TicksPerMillisecond;
+ }
+ }
+
+ static PerformanceCounter()
+ {
+ TicksPerMillisecond = Stopwatch.Frequency / 1000;
+ TicksPerSecond = Stopwatch.Frequency;
+ TicksPerMinute = TicksPerSecond * 60;
+ TicksPerHour = TicksPerMinute * 60;
+ TicksPerDay = TicksPerHour * 24;
+ }
+ }
+}