Some misc performance changes + logging

This commit is contained in:
Zeffuro
2026-01-11 05:09:28 +01:00
parent 51934eb23d
commit 6d15ee1b13
5 changed files with 73 additions and 14 deletions
+23
View File
@@ -62,6 +62,10 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
private readonly HashSet<uint> _searchMatchScratch = new();
private bool _isRefreshing;
private int _requestedUpdateCount;
private int _refreshFromLifecycleCount;
private long _lastLogTick;
public void ManualRefresh()
{
if (!IsOpen) return;
@@ -104,6 +108,10 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
try
{
_isRefreshing = true;
_refreshFromLifecycleCount++;
LogRefreshStats();
InventoryState.RefreshFromGame();
RefreshCategoriesCore(autosize: true);
}
@@ -405,8 +413,23 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
RefreshCategoriesCore(false);
}
private void LogRefreshStats()
{
long now = Environment.TickCount64;
if (now - _lastLogTick > 1000) // Log every second
{
Services.Logger.DebugOnly($"[Perf] Last 1s: OnRequestedUpdate={_requestedUpdateCount}, RefreshFromLifecycle={_refreshFromLifecycleCount}");
_requestedUpdateCount = 0;
_refreshFromLifecycleCount = 0;
_lastLogTick = now;
}
}
protected override void OnRequestedUpdate(AtkUnitBase* addon, NumberArrayData** numberArrayData, StringArrayData** stringArrayData)
{
_requestedUpdateCount++;
LogRefreshStats();
base.OnRequestedUpdate(addon, numberArrayData, stringArrayData);
if (DragDropState.IsDragging)