mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Add temporary wiki open frame timing diagnostics
This commit is contained in:
1 parent
ff17c946a4
commit
cb292308c4
1 file changed
+47
@@ -59,6 +59,7 @@ public static class RoleGuidePatches
|
|||||||
private static IEnumerator? _reveal;
|
private static IEnumerator? _reveal;
|
||||||
private static bool _pendingRefresh;
|
private static bool _pendingRefresh;
|
||||||
private static int _revealedThisFrame;
|
private static int _revealedThisFrame;
|
||||||
|
private static IEnumerator? _perfLogger;
|
||||||
private static LoadingRing? _loadingSpinner;
|
private static LoadingRing? _loadingSpinner;
|
||||||
private static SortingFilter _sortFilter = SortingFilter.EnabledOnly;
|
private static SortingFilter _sortFilter = SortingFilter.EnabledOnly;
|
||||||
private static SortingMethod _sortMethod = SortingMethod.Alphabetical;
|
private static SortingMethod _sortMethod = SortingMethod.Alphabetical;
|
||||||
@@ -116,6 +117,13 @@ public static class RoleGuidePatches
|
|||||||
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Open))]
|
[HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Open))]
|
||||||
public static bool Open(MatchInfoGuide __instance)
|
public static bool Open(MatchInfoGuide __instance)
|
||||||
{
|
{
|
||||||
|
if (_perfLogger != null)
|
||||||
|
{
|
||||||
|
Coroutines.Stop(_perfLogger);
|
||||||
|
}
|
||||||
|
|
||||||
|
_perfLogger = Coroutines.Start(CoLogOpenFrames(__instance.NormalModeSettings.Count == 0 ? "first-open" : "reopen"));
|
||||||
|
var perfWatch = System.Diagnostics.Stopwatch.StartNew();
|
||||||
if (HudManager.Instance.GameMenu.IsOpen || HudManager.Instance.Chat.IsOpenOrOpening)
|
if (HudManager.Instance.GameMenu.IsOpen || HudManager.Instance.Chat.IsOpenOrOpening)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -413,6 +421,8 @@ public static class RoleGuidePatches
|
|||||||
__instance.CreateHnSModeSettings();
|
__instance.CreateHnSModeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prepMs = perfWatch.ElapsedMilliseconds;
|
||||||
|
perfWatch.Restart();
|
||||||
PlayerControl.LocalPlayer.NetTransform.Halt();
|
PlayerControl.LocalPlayer.NetTransform.Halt();
|
||||||
__instance.MatchInfoParent.SetActive(true);
|
__instance.MatchInfoParent.SetActive(true);
|
||||||
if (__instance.ControllerSelectable.Count > 0)
|
if (__instance.ControllerSelectable.Count > 0)
|
||||||
@@ -425,7 +435,16 @@ public static class RoleGuidePatches
|
|||||||
controllerManager.SetCurrentSelected(__instance.ControllerSelectable[^1]);
|
controllerManager.SetCurrentSelected(__instance.ControllerSelectable[^1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showMs = perfWatch.ElapsedMilliseconds;
|
||||||
|
perfWatch.Restart();
|
||||||
__instance.SetActiveTab(regGame ? RolesTabIndex : 0);
|
__instance.SetActiveTab(regGame ? RolesTabIndex : 0);
|
||||||
|
Debug(
|
||||||
|
$"[WikiPerf] open: prep {prepMs}ms, show {showMs}ms, tab {perfWatch.ElapsedMilliseconds}ms");
|
||||||
|
Debug(
|
||||||
|
$"[WikiPerf] panels: roles {RolePanels.Count} " +
|
||||||
|
$"({RolePanels.Values.Count(h => h.Panel.gameObject.activeSelf)}), " +
|
||||||
|
$"modifiers {ModifierPanels.Count} " +
|
||||||
|
$"({ModifierPanels.Values.Count(h => h.Panel.gameObject.activeSelf)})");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,6 +646,34 @@ public static class RoleGuidePatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerator CoLogOpenFrames(string label)
|
||||||
|
{
|
||||||
|
var frames = 0;
|
||||||
|
var worst = 0f;
|
||||||
|
var worstIdx = 0;
|
||||||
|
while (frames < 90)
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
frames++;
|
||||||
|
var ms = Time.unscaledDeltaTime * 1000f;
|
||||||
|
if (ms > worst)
|
||||||
|
{
|
||||||
|
worst = ms;
|
||||||
|
worstIdx = frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ms > 33f)
|
||||||
|
{
|
||||||
|
Debug(
|
||||||
|
$"[WikiPerf] frame +{frames}: {ms:F0}ms (reveal={_reveal != null}, " +
|
||||||
|
$"panelsReady={_panelsReady}, revealedThisFrame={_revealedThisFrame})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug($"[WikiPerf] done ({label}): worst {worst:F0}ms at +{worstIdx}");
|
||||||
|
_perfLogger = null;
|
||||||
|
}
|
||||||
|
|
||||||
private static void RefreshActiveTab(bool scrollToTop)
|
private static void RefreshActiveTab(bool scrollToTop)
|
||||||
{
|
{
|
||||||
if (!_panelsReady)
|
if (!_panelsReady)
|
||||||
|
|||||||
Reference in new issue
Block a user