diff options
author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
---|---|---|
committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.Cpu/TickSource.cs | |
parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.Cpu/TickSource.cs')
-rw-r--r-- | src/Ryujinx.Cpu/TickSource.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Ryujinx.Cpu/TickSource.cs b/src/Ryujinx.Cpu/TickSource.cs new file mode 100644 index 00000000..dc510bc2 --- /dev/null +++ b/src/Ryujinx.Cpu/TickSource.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; + +namespace Ryujinx.Cpu +{ + public class TickSource : ITickSource + { + private static Stopwatch _tickCounter; + + private static double _hostTickFreq; + + /// <inheritdoc/> + public ulong Frequency { get; } + + /// <inheritdoc/> + public ulong Counter => (ulong)(ElapsedSeconds * Frequency); + + /// <inheritdoc/> + public TimeSpan ElapsedTime => _tickCounter.Elapsed; + + /// <inheritdoc/> + public double ElapsedSeconds => _tickCounter.ElapsedTicks * _hostTickFreq; + + public TickSource(ulong frequency) + { + Frequency = frequency; + _hostTickFreq = 1.0 / Stopwatch.Frequency; + + _tickCounter = new Stopwatch(); + _tickCounter.Start(); + } + + /// <inheritdoc/> + public void Suspend() + { + _tickCounter.Stop(); + } + + /// <inheritdoc/> + public void Resume() + { + _tickCounter.Start(); + } + } +}
\ No newline at end of file |