mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 13:14:17 +01:00
use stopwatch for more precise delta
This commit is contained in:
parent
8ed050e41f
commit
01c0e21440
1 changed files with 16 additions and 4 deletions
|
|
@ -25,6 +25,7 @@ namespace Dalamud.Game
|
||||||
public sealed class Framework : IDisposable
|
public sealed class Framework : IDisposable
|
||||||
{
|
{
|
||||||
private static Stopwatch statsStopwatch = new();
|
private static Stopwatch statsStopwatch = new();
|
||||||
|
private Stopwatch updateStopwatch = new();
|
||||||
|
|
||||||
private Hook<OnUpdateDetour> updateHook;
|
private Hook<OnUpdateDetour> updateHook;
|
||||||
private Hook<OnDestroyDetour> destroyHook;
|
private Hook<OnDestroyDetour> destroyHook;
|
||||||
|
|
@ -93,10 +94,15 @@ namespace Dalamud.Game
|
||||||
public FrameworkAddressResolver Address { get; }
|
public FrameworkAddressResolver Address { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the last time the Framework Update event was triggered.
|
/// Gets the last time that the Framework Update event was triggered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime LastUpdate { get; private set; } = DateTime.MinValue;
|
public DateTime LastUpdate { get; private set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the last time in UTC that the Framework Update event was triggered.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LastUpdateUTC { get; private set; } = DateTime.MinValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the delta between the last Framework Update and the currently executing one.
|
/// Gets the delta between the last Framework Update and the currently executing one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -137,6 +143,9 @@ namespace Dalamud.Game
|
||||||
this.updateHook?.Dispose();
|
this.updateHook?.Dispose();
|
||||||
this.destroyHook?.Dispose();
|
this.destroyHook?.Dispose();
|
||||||
this.realDestroyHook?.Dispose();
|
this.realDestroyHook?.Dispose();
|
||||||
|
|
||||||
|
this.updateStopwatch.Reset();
|
||||||
|
statsStopwatch.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HookVTable()
|
private void HookVTable()
|
||||||
|
|
@ -183,9 +192,12 @@ namespace Dalamud.Game
|
||||||
|
|
||||||
if (this.DispatchUpdateEvents)
|
if (this.DispatchUpdateEvents)
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
this.updateStopwatch.Stop();
|
||||||
this.UpdateDelta = now - this.LastUpdate;
|
this.UpdateDelta = TimeSpan.FromMilliseconds(this.updateStopwatch.ElapsedMilliseconds);
|
||||||
this.LastUpdate = now;
|
this.updateStopwatch.Restart();
|
||||||
|
|
||||||
|
this.LastUpdate = DateTime.Now;
|
||||||
|
this.LastUpdateUTC = DateTime.UtcNow;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue