diff --git a/Ryujinx.Core/Logging.cs b/Ryujinx.Core/Logging.cs index 06e94f21fb..d544a5d64f 100644 --- a/Ryujinx.Core/Logging.cs +++ b/Ryujinx.Core/Logging.cs @@ -8,6 +8,7 @@ namespace Ryujinx.Core { public static class Logging { + private static Stopwatch ExecutionTime = new Stopwatch(); private const string LogFileName = "Ryujinx.log"; private static bool EnableInfo = Config.LoggingEnableInfo; @@ -26,7 +27,7 @@ namespace Ryujinx.Core public static string GetExecutionTime() { - return PerformanceStatistics.ElapsedMilliseconds.ToString().PadLeft(8, '0') + "ms"; + return ExecutionTime.ElapsedMilliseconds.ToString().PadLeft(8, '0') + "ms"; } private static string WhoCalledMe() diff --git a/Ryujinx.Core/OsHle/Services/Vi/NvFlinger.cs b/Ryujinx.Core/OsHle/Services/Vi/NvFlinger.cs index 6ab2f930e6..720dd44f93 100644 --- a/Ryujinx.Core/OsHle/Services/Vi/NvFlinger.cs +++ b/Ryujinx.Core/OsHle/Services/Vi/NvFlinger.cs @@ -154,7 +154,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Android private long GbpQueueBuffer(ServiceCtx Context, BinaryReader ParcelReader) { - PerformanceStatistics.RecordGameFrameTime(); + Context.Ns.Statistics.RecordGameFrameTime(); //TODO: Errors. int Slot = ParcelReader.ReadInt32(); diff --git a/Ryujinx.Core/PerformanceStatistics.cs b/Ryujinx.Core/PerformanceStatistics.cs index de487563af..57a43961ed 100644 --- a/Ryujinx.Core/PerformanceStatistics.cs +++ b/Ryujinx.Core/PerformanceStatistics.cs @@ -5,50 +5,50 @@ using System.Text; namespace Ryujinx.Core { - public static class PerformanceStatistics + public class PerformanceStatistics { - static Stopwatch ExecutionTime = new Stopwatch(); + Stopwatch ExecutionTime = new Stopwatch(); - static long CurrentGameFrameEnded; - static long CurrentSystemFrameEnded; - static long CurrentSystemFrameStart; - static long LastGameFrameEnded; - static long LastSystemFrameEnded; + long CurrentGameFrameEnded; + long CurrentSystemFrameEnded; + long CurrentSystemFrameStart; + long LastGameFrameEnded; + long LastSystemFrameEnded; - public static double CurrentGameFrameTime; - public static double CurrentSystemFrameTime; - public static double PreviousGameFrameTime; - public static double PreviousSystemFrameTime; - public static double GameFrameRate => 1000f / (CurrentSystemFrameTime / 1000); - public static double SystemFrameRate => 1000f/(CurrentSystemFrameTime/1000); - public static long SystemFramesRendered; - public static long GameFramesRendered; - public static long ElapsedMilliseconds { get => ExecutionTime.ElapsedMilliseconds; } - public static long ElapsedMicroseconds { get => (long) + public double CurrentGameFrameTime; + public double CurrentSystemFrameTime; + public double PreviousGameFrameTime; + public double PreviousSystemFrameTime; + public double GameFrameRate => 1000f / (CurrentSystemFrameTime / 1000); + public double SystemFrameRate => 1000f/(CurrentSystemFrameTime/1000); + public long SystemFramesRendered; + public long GameFramesRendered; + public long ElapsedMilliseconds { get => ExecutionTime.ElapsedMilliseconds; } + public long ElapsedMicroseconds { get => (long) (((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000); } - public static long ElapsedNanoseconds { get => (long) + public long ElapsedNanoseconds { get => (long) (((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000000); } - static PerformanceStatistics() + public PerformanceStatistics() { ExecutionTime.Start(); } - public static void StartSystemFrame() + public void StartSystemFrame() { PreviousSystemFrameTime = CurrentSystemFrameTime; LastSystemFrameEnded = CurrentSystemFrameEnded; CurrentSystemFrameStart = ElapsedMicroseconds; } - public static void EndSystemFrame() + public void EndSystemFrame() { CurrentSystemFrameEnded = ElapsedMicroseconds; CurrentSystemFrameTime = CurrentSystemFrameEnded - CurrentSystemFrameStart; SystemFramesRendered++; } - public static void RecordGameFrameTime() + public void RecordGameFrameTime() { CurrentGameFrameEnded = ElapsedMicroseconds; CurrentGameFrameTime = CurrentGameFrameEnded - LastGameFrameEnded; diff --git a/Ryujinx.Core/Switch.cs b/Ryujinx.Core/Switch.cs index 3f7b1e2b81..1acd87f018 100644 --- a/Ryujinx.Core/Switch.cs +++ b/Ryujinx.Core/Switch.cs @@ -17,8 +17,9 @@ namespace Ryujinx.Core internal Horizon Os { get; private set; } internal VirtualFs VFs { get; private set; } - public Hid Hid { get; private set; } - public SetSys Settings { get; private set; } + public Hid Hid { get; private set; } + public SetSys Settings { get; private set; } + public PerformanceStatistics Statistics { get; private set; } public event EventHandler Finish; @@ -32,6 +33,8 @@ namespace Ryujinx.Core Hid = new Hid(Ram); + Statistics = new PerformanceStatistics(); + Os = new Horizon(this); Os.HidSharedMem.MemoryMapped += Hid.ShMemMap; diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 0a58481271..b0dca81b77 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -166,12 +166,12 @@ namespace Ryujinx protected override void OnRenderFrame(FrameEventArgs e) { - PerformanceStatistics.StartSystemFrame(); + Ns.Statistics.StartSystemFrame(); GL.Viewport(0, 0, Width, Height); - Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {PerformanceStatistics.SystemFrameRate:0} - Guest FPS: " + - $"{PerformanceStatistics.GameFrameRate:0})"; + Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {Ns.Statistics.SystemFrameRate:0} - Guest FPS: " + + $"{Ns.Statistics.GameFrameRate:0})"; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); @@ -180,7 +180,7 @@ namespace Ryujinx SwapBuffers(); - PerformanceStatistics.EndSystemFrame(); + Ns.Statistics.EndSystemFrame(); } protected override void OnResize(EventArgs e)