From 44a65f61fb5ef2c7e31a79978614fac908608aab Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 24 Dec 2023 13:38:29 +0100 Subject: [PATCH] Add diagnostic display and make CustomizeManager a DataContainer. --- Glamourer/GameData/CustomizeManager.cs | 28 ++++++++++++++++--- Glamourer/GameData/CustomizeSetFactory.cs | 4 +-- Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs | 1 + OtterGui | 2 +- Penumbra.GameData | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Glamourer/GameData/CustomizeManager.cs b/Glamourer/GameData/CustomizeManager.cs index 6f03881..a78cdc0 100644 --- a/Glamourer/GameData/CustomizeManager.cs +++ b/Glamourer/GameData/CustomizeManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Dalamud.Interface.Internal; @@ -12,7 +13,7 @@ using Race = Penumbra.GameData.Enums.Race; namespace Glamourer.GameData; /// Generate everything about customization per tribe and gender. -public class CustomizeManager : IAsyncService +public class CustomizeManager : IAsyncDataContainer { /// All races except for Unknown public static readonly IReadOnlyList Races = ((Race[])Enum.GetValues(typeof(Race))).Skip(1).ToArray(); @@ -52,10 +53,21 @@ public class CustomizeManager : IAsyncService public CustomizeManager(ITextureProvider textures, IDataManager gameData, IPluginLog log, NpcCustomizeSet npcCustomizeSet) { _icons = new IconStorage(textures, gameData); - var tmpTask = Task.Run(() => new CustomizeSetFactory(gameData, log, _icons, npcCustomizeSet)); + var stopwatch = new Stopwatch(); + var tmpTask = Task.Run(() => + { + stopwatch.Start(); + return new CustomizeSetFactory(gameData, log, _icons, npcCustomizeSet); + }); var setTasks = AllSets().Select(p => tmpTask.ContinueWith(t => _customizationSets[ToIndex(p.Clan, p.Gender)] = t.Result.CreateSet(p.Clan, p.Gender))); - Awaiter = Task.WhenAll(setTasks); + Awaiter = Task.WhenAll(setTasks).ContinueWith(_ => + { + // This is far too hard to estimate sensibly. + TotalCount = 0; + Memory = 0; + Time = stopwatch.ElapsedMilliseconds; + }); } /// @@ -78,4 +90,12 @@ public class CustomizeManager : IAsyncService return idx; } -} \ No newline at end of file + + public long Time { get; private set; } + public long Memory { get; private set; } + + public string Name + => nameof(CustomizeManager); + + public int TotalCount { get; private set; } +} diff --git a/Glamourer/GameData/CustomizeSetFactory.cs b/Glamourer/GameData/CustomizeSetFactory.cs index 5eaaa58..6099344 100644 --- a/Glamourer/GameData/CustomizeSetFactory.cs +++ b/Glamourer/GameData/CustomizeSetFactory.cs @@ -274,7 +274,7 @@ internal class CustomizeSetFactory( { // If none exists and the id corresponds to highlights, set the Highlights name. if (c == CustomizeIndex.Highlights) - return _lobbySheet.GetRow(237)?.Text.ToDalamudString().ToString() ?? "Highlights"; + return string.Intern(_lobbySheet.GetRow(237)?.Text.ToDalamudString().ToString() ?? "Highlights"); // Otherwise there is an error and we use the default name. return c.ToDefaultName(); @@ -282,7 +282,7 @@ internal class CustomizeSetFactory( // Otherwise all is normal, get the menu name or if it does not work the default name. var textRow = _lobbySheet.GetRow(menu.Value.Id); - return textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName(); + return string.Intern(textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName()); }).ToArray(); // Add names for both eye colors. diff --git a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs index cb50b88..7c50f4d 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs @@ -45,6 +45,7 @@ public class DebugTabHeader(string label, params IGameDataDrawer[] subTrees) => new ( "Game Data", + provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), provider.GetRequiredService(), diff --git a/OtterGui b/OtterGui index bdf053e..4df65fb 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit bdf053ea9e7ac7b96dcd6aceadff8d92c3050b34 +Subproject commit 4df65fb330f3746b7836c39cb96d1e36a53bcec0 diff --git a/Penumbra.GameData b/Penumbra.GameData index a7d2d73..3073db1 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit a7d2d73217113eadf02e21865a82deb92ea9eb53 +Subproject commit 3073db1fc8a1894a4af8974ea9c22a63acd7316e