aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/PerformanceCounter.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-10-13 03:02:07 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit1876b346fea647e8284a66bb6d62c38801035cff (patch)
tree6eeff094298cda84d1613dc5ec0691e51d7b35f1 /Ryujinx.Common/PerformanceCounter.cs
parentf617fb542a0e3d36012d77a4b5acbde7b08902f2 (diff)
Initial work
Diffstat (limited to 'Ryujinx.Common/PerformanceCounter.cs')
-rw-r--r--Ryujinx.Common/PerformanceCounter.cs21
1 files changed, 19 insertions, 2 deletions
diff --git a/Ryujinx.Common/PerformanceCounter.cs b/Ryujinx.Common/PerformanceCounter.cs
index 4c8ae6a7..1c2782e3 100644
--- a/Ryujinx.Common/PerformanceCounter.cs
+++ b/Ryujinx.Common/PerformanceCounter.cs
@@ -1,9 +1,11 @@
-using System.Diagnostics;
+using System.Diagnostics;
namespace Ryujinx.Common
{
public static class PerformanceCounter
{
+ private static double _ticksToNs;
+
/// <summary>
/// Represents the number of ticks in 1 day.
/// </summary>
@@ -53,6 +55,19 @@ namespace Ryujinx.Common
}
}
+ /// <summary>
+ /// Gets the number of nanoseconds elapsed since the system started.
+ /// </summary>
+ public static long ElapsedNanoseconds
+ {
+ get
+ {
+ long timestamp = Stopwatch.GetTimestamp();
+
+ return (long)(timestamp * _ticksToNs);
+ }
+ }
+
static PerformanceCounter()
{
TicksPerMillisecond = Stopwatch.Frequency / 1000;
@@ -60,6 +75,8 @@ namespace Ryujinx.Common
TicksPerMinute = TicksPerSecond * 60;
TicksPerHour = TicksPerMinute * 60;
TicksPerDay = TicksPerHour * 24;
+
+ _ticksToNs = 1000000000.0 / (double)Stopwatch.Frequency;
}
}
-}
+} \ No newline at end of file