mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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
|
||||
{
|
||||
private static Stopwatch statsStopwatch = new();
|
||||
private Stopwatch updateStopwatch = new();
|
||||
|
||||
private Hook<OnUpdateDetour> updateHook;
|
||||
private Hook<OnDestroyDetour> destroyHook;
|
||||
|
|
@ -93,10 +94,15 @@ namespace Dalamud.Game
|
|||
public FrameworkAddressResolver Address { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last time the Framework Update event was triggered.
|
||||
/// Gets the last time that the Framework Update event was triggered.
|
||||
/// </summary>
|
||||
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>
|
||||
/// Gets the delta between the last Framework Update and the currently executing one.
|
||||
/// </summary>
|
||||
|
|
@ -137,6 +143,9 @@ namespace Dalamud.Game
|
|||
this.updateHook?.Dispose();
|
||||
this.destroyHook?.Dispose();
|
||||
this.realDestroyHook?.Dispose();
|
||||
|
||||
this.updateStopwatch.Reset();
|
||||
statsStopwatch.Reset();
|
||||
}
|
||||
|
||||
private void HookVTable()
|
||||
|
|
@ -183,9 +192,12 @@ namespace Dalamud.Game
|
|||
|
||||
if (this.DispatchUpdateEvents)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
this.UpdateDelta = now - this.LastUpdate;
|
||||
this.LastUpdate = now;
|
||||
this.updateStopwatch.Stop();
|
||||
this.UpdateDelta = TimeSpan.FromMilliseconds(this.updateStopwatch.ElapsedMilliseconds);
|
||||
this.updateStopwatch.Restart();
|
||||
|
||||
this.LastUpdate = DateTime.Now;
|
||||
this.LastUpdateUTC = DateTime.UtcNow;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue