Be explicit about rounding for the FPS display, rename method
This commit is contained in:
parent
1f580aa826
commit
a3ac843c76
|
@ -1611,6 +1611,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private readonly double _fpsUpdatesPerSecond = 4.0;
|
private readonly double _fpsUpdatesPerSecond = 4.0;
|
||||||
private readonly double _fpsSmoothing = 8.0;
|
private readonly double _fpsSmoothing = 8.0;
|
||||||
private double _lastFps;
|
private double _lastFps;
|
||||||
|
private int _lastFpsRounded;
|
||||||
private int _framesSinceLastFpsUpdate;
|
private int _framesSinceLastFpsUpdate;
|
||||||
private long _timestampLastFpsUpdate;
|
private long _timestampLastFpsUpdate;
|
||||||
|
|
||||||
|
@ -3145,7 +3146,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
_framesSinceLastFpsUpdate++;
|
_framesSinceLastFpsUpdate++;
|
||||||
|
|
||||||
UpdateFpsDisplay(currentTimestamp, isRewinding, isFastForwarding);
|
CalcFramerateAndUpdateDisplay(currentTimestamp, isRewinding, isFastForwarding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools.IsLoaded<TAStudio>() &&
|
if (Tools.IsLoaded<TAStudio>() &&
|
||||||
|
@ -3183,7 +3184,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Sound.UpdateSound(atten, DisableSecondaryThrottling);
|
Sound.UpdateSound(atten, DisableSecondaryThrottling);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateFpsDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding)
|
private void CalcFramerateAndUpdateDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding)
|
||||||
{
|
{
|
||||||
double elapsedSeconds = (currentTimestamp - _timestampLastFpsUpdate) / (double)Stopwatch.Frequency;
|
double elapsedSeconds = (currentTimestamp - _timestampLastFpsUpdate) / (double)Stopwatch.Frequency;
|
||||||
|
|
||||||
|
@ -3200,11 +3201,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
_lastFps = (_lastFps + (_framesSinceLastFpsUpdate * _fpsSmoothing)) / (1.0 + (elapsedSeconds * _fpsSmoothing));
|
_lastFps = (_lastFps + (_framesSinceLastFpsUpdate * _fpsSmoothing)) / (1.0 + (elapsedSeconds * _fpsSmoothing));
|
||||||
}
|
}
|
||||||
|
_lastFpsRounded = (int) Math.Round(_lastFps);
|
||||||
|
|
||||||
_framesSinceLastFpsUpdate = 0;
|
_framesSinceLastFpsUpdate = 0;
|
||||||
_timestampLastFpsUpdate = currentTimestamp;
|
_timestampLastFpsUpdate = currentTimestamp;
|
||||||
|
|
||||||
var fpsString = $"{_lastFps:0} fps";
|
var fpsString = $"{_lastFpsRounded} fps";
|
||||||
if (isRewinding)
|
if (isRewinding)
|
||||||
{
|
{
|
||||||
fpsString += IsTurboing || isFastForwarding ?
|
fpsString += IsTurboing || isFastForwarding ?
|
||||||
|
@ -3229,7 +3231,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void InitializeFpsData()
|
private void InitializeFpsData()
|
||||||
{
|
{
|
||||||
_lastFps = 0;
|
_lastFps = _lastFpsRounded = 0;
|
||||||
_timestampLastFpsUpdate = Stopwatch.GetTimestamp();
|
_timestampLastFpsUpdate = Stopwatch.GetTimestamp();
|
||||||
_framesSinceLastFpsUpdate = 0;
|
_framesSinceLastFpsUpdate = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue