made performancestatictics class non-static

This commit is contained in:
emmaus 2018-03-06 18:14:22 +00:00
commit f5376a48a7
5 changed files with 34 additions and 30 deletions

View file

@ -8,6 +8,7 @@ namespace Ryujinx.Core
{ {
public static class Logging public static class Logging
{ {
private static Stopwatch ExecutionTime = new Stopwatch();
private const string LogFileName = "Ryujinx.log"; private const string LogFileName = "Ryujinx.log";
private static bool EnableInfo = Config.LoggingEnableInfo; private static bool EnableInfo = Config.LoggingEnableInfo;
@ -26,7 +27,7 @@ namespace Ryujinx.Core
public static string GetExecutionTime() public static string GetExecutionTime()
{ {
return PerformanceStatistics.ElapsedMilliseconds.ToString().PadLeft(8, '0') + "ms"; return ExecutionTime.ElapsedMilliseconds.ToString().PadLeft(8, '0') + "ms";
} }
private static string WhoCalledMe() private static string WhoCalledMe()

View file

@ -154,7 +154,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Android
private long GbpQueueBuffer(ServiceCtx Context, BinaryReader ParcelReader) private long GbpQueueBuffer(ServiceCtx Context, BinaryReader ParcelReader)
{ {
PerformanceStatistics.RecordGameFrameTime(); Context.Ns.Statistics.RecordGameFrameTime();
//TODO: Errors. //TODO: Errors.
int Slot = ParcelReader.ReadInt32(); int Slot = ParcelReader.ReadInt32();

View file

@ -5,50 +5,50 @@ using System.Text;
namespace Ryujinx.Core namespace Ryujinx.Core
{ {
public static class PerformanceStatistics public class PerformanceStatistics
{ {
static Stopwatch ExecutionTime = new Stopwatch(); Stopwatch ExecutionTime = new Stopwatch();
static long CurrentGameFrameEnded; long CurrentGameFrameEnded;
static long CurrentSystemFrameEnded; long CurrentSystemFrameEnded;
static long CurrentSystemFrameStart; long CurrentSystemFrameStart;
static long LastGameFrameEnded; long LastGameFrameEnded;
static long LastSystemFrameEnded; long LastSystemFrameEnded;
public static double CurrentGameFrameTime; public double CurrentGameFrameTime;
public static double CurrentSystemFrameTime; public double CurrentSystemFrameTime;
public static double PreviousGameFrameTime; public double PreviousGameFrameTime;
public static double PreviousSystemFrameTime; public double PreviousSystemFrameTime;
public static double GameFrameRate => 1000f / (CurrentSystemFrameTime / 1000); public double GameFrameRate => 1000f / (CurrentSystemFrameTime / 1000);
public static double SystemFrameRate => 1000f/(CurrentSystemFrameTime/1000); public double SystemFrameRate => 1000f/(CurrentSystemFrameTime/1000);
public static long SystemFramesRendered; public long SystemFramesRendered;
public static long GameFramesRendered; public long GameFramesRendered;
public static long ElapsedMilliseconds { get => ExecutionTime.ElapsedMilliseconds; } public long ElapsedMilliseconds { get => ExecutionTime.ElapsedMilliseconds; }
public static long ElapsedMicroseconds { get => (long) public long ElapsedMicroseconds { get => (long)
(((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000); } (((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000); }
public static long ElapsedNanoseconds { get => (long) public long ElapsedNanoseconds { get => (long)
(((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000000); } (((double)ExecutionTime.ElapsedTicks / Stopwatch.Frequency) * 1000000000); }
static PerformanceStatistics() public PerformanceStatistics()
{ {
ExecutionTime.Start(); ExecutionTime.Start();
} }
public static void StartSystemFrame() public void StartSystemFrame()
{ {
PreviousSystemFrameTime = CurrentSystemFrameTime; PreviousSystemFrameTime = CurrentSystemFrameTime;
LastSystemFrameEnded = CurrentSystemFrameEnded; LastSystemFrameEnded = CurrentSystemFrameEnded;
CurrentSystemFrameStart = ElapsedMicroseconds; CurrentSystemFrameStart = ElapsedMicroseconds;
} }
public static void EndSystemFrame() public void EndSystemFrame()
{ {
CurrentSystemFrameEnded = ElapsedMicroseconds; CurrentSystemFrameEnded = ElapsedMicroseconds;
CurrentSystemFrameTime = CurrentSystemFrameEnded - CurrentSystemFrameStart; CurrentSystemFrameTime = CurrentSystemFrameEnded - CurrentSystemFrameStart;
SystemFramesRendered++; SystemFramesRendered++;
} }
public static void RecordGameFrameTime() public void RecordGameFrameTime()
{ {
CurrentGameFrameEnded = ElapsedMicroseconds; CurrentGameFrameEnded = ElapsedMicroseconds;
CurrentGameFrameTime = CurrentGameFrameEnded - LastGameFrameEnded; CurrentGameFrameTime = CurrentGameFrameEnded - LastGameFrameEnded;

View file

@ -17,8 +17,9 @@ namespace Ryujinx.Core
internal Horizon Os { get; private set; } internal Horizon Os { get; private set; }
internal VirtualFs VFs { get; private set; } internal VirtualFs VFs { get; private set; }
public Hid Hid { get; private set; } public Hid Hid { get; private set; }
public SetSys Settings { get; private set; } public SetSys Settings { get; private set; }
public PerformanceStatistics Statistics { get; private set; }
public event EventHandler Finish; public event EventHandler Finish;
@ -32,6 +33,8 @@ namespace Ryujinx.Core
Hid = new Hid(Ram); Hid = new Hid(Ram);
Statistics = new PerformanceStatistics();
Os = new Horizon(this); Os = new Horizon(this);
Os.HidSharedMem.MemoryMapped += Hid.ShMemMap; Os.HidSharedMem.MemoryMapped += Hid.ShMemMap;

View file

@ -166,12 +166,12 @@ namespace Ryujinx
protected override void OnRenderFrame(FrameEventArgs e) protected override void OnRenderFrame(FrameEventArgs e)
{ {
PerformanceStatistics.StartSystemFrame(); Ns.Statistics.StartSystemFrame();
GL.Viewport(0, 0, Width, Height); GL.Viewport(0, 0, Width, Height);
Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {PerformanceStatistics.SystemFrameRate:0} - Guest FPS: " + Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {Ns.Statistics.SystemFrameRate:0} - Guest FPS: " +
$"{PerformanceStatistics.GameFrameRate:0})"; $"{Ns.Statistics.GameFrameRate:0})";
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
@ -180,7 +180,7 @@ namespace Ryujinx
SwapBuffers(); SwapBuffers();
PerformanceStatistics.EndSystemFrame(); Ns.Statistics.EndSystemFrame();
} }
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)