Adjustments to framerate metric and addition of frametime (#2638)

* Adjust framerate data and add frametime

* Update PerformanceStatistics.cs

* Revert deletions of average framerate

* Update Ryujinx.csproj

* Remove separate GTK column

* Increase FPS precision

* general cleanup

* even generaler cleanup

* fix dumb

* Remove legacy code

* Update PerformanceStatistics.cs

* Update PerformanceStatistics.cs
This commit is contained in:
MutantAura 2021-09-15 01:26:10 +01:00 committed by GitHub
parent fb2e61a435
commit 843401635a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 17 deletions

View file

@ -5,11 +5,10 @@ namespace Ryujinx.HLE
{
public class PerformanceStatistics
{
private const double FrameRateWeight = 0.5;
private const int FrameTypeGame = 0;
private const int PercentTypeFifo = 0;
private const int FrameTypeGame = 0;
private const int PercentTypeFifo = 0;
private double[] _averageFrameRate;
private double[] _frameRate;
private double[] _accumulatedFrameTime;
private double[] _previousFrameTime;
@ -30,7 +29,7 @@ namespace Ryujinx.HLE
public PerformanceStatistics()
{
_averageFrameRate = new double[1];
_frameRate = new double[1];
_accumulatedFrameTime = new double[1];
_previousFrameTime = new double[1];
@ -45,7 +44,7 @@ namespace Ryujinx.HLE
_frameLock = new object[] { new object() };
_percentLock = new object[] { new object() };
_resetTimer = new Timer(1000);
_resetTimer = new Timer(750);
_resetTimer.Elapsed += ResetTimerElapsed;
_resetTimer.AutoReset = true;
@ -57,11 +56,11 @@ namespace Ryujinx.HLE
private void ResetTimerElapsed(object sender, ElapsedEventArgs e)
{
CalculateAverageFrameRate(FrameTypeGame);
CalculateFrameRate(FrameTypeGame);
CalculateAveragePercent(PercentTypeFifo);
}
private void CalculateAverageFrameRate(int frameType)
private void CalculateFrameRate(int frameType)
{
double frameRate = 0;
@ -72,7 +71,7 @@ namespace Ryujinx.HLE
frameRate = _framesRendered[frameType] / _accumulatedFrameTime[frameType];
}
_averageFrameRate[frameType] = LinearInterpolate(_averageFrameRate[frameType], frameRate);
_frameRate[frameType] = frameRate;
_framesRendered[frameType] = 0;
_accumulatedFrameTime[frameType] = 0;
}
@ -97,11 +96,6 @@ namespace Ryujinx.HLE
}
}
private static double LinearInterpolate(double lhs, double rhs)
{
return lhs * (1.0 - FrameRateWeight) + rhs * FrameRateWeight;
}
public void RecordGameFrameTime()
{
RecordFrameTime(FrameTypeGame);
@ -157,12 +151,17 @@ namespace Ryujinx.HLE
public double GetGameFrameRate()
{
return _averageFrameRate[FrameTypeGame];
return _frameRate[FrameTypeGame];
}
public double GetFifoPercent()
{
return _averagePercent[PercentTypeFifo];
}
public double GetGameFrameTime()
{
return 1000 / _frameRate[FrameTypeGame];
}
}
}

View file

@ -198,7 +198,7 @@ namespace Ryujinx.Headless.SDL2
Device.EnableDeviceVsync,
dockedMode,
Device.Configuration.AspectRatio.ToText(),
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS",
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
$"GPU: {_gpuVendorName}"));

View file

@ -427,7 +427,7 @@ namespace Ryujinx.Ui
Device.EnableDeviceVsync,
dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS",
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
$"FIFO: {Device.Statistics.GetFifoPercent():0.00} %",
$"GPU: {_gpuVendorName}"));