chore: add some timings for Tier 2 init

This commit is contained in:
goaaats 2022-06-21 21:52:44 +02:00
parent 8d33252cee
commit c72581d3bb
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 67 additions and 41 deletions

View file

@ -185,21 +185,27 @@ namespace Dalamud
Service<NetworkHandlers>.Set(); Service<NetworkHandlers>.Set();
Log.Information("[T2] NH OK!"); Log.Information("[T2] NH OK!");
try using (Timings.Start("DM Init"))
{ {
Service<DataManager>.Set().Initialize(this.AssetDirectory.FullName); try
} {
catch (Exception e) Service<DataManager>.Set().Initialize(this.AssetDirectory.FullName);
{ }
Log.Error(e, "Could not initialize DataManager."); catch (Exception e)
this.Unload(); {
return false; Log.Error(e, "Could not initialize DataManager");
this.Unload();
return false;
}
} }
Log.Information("[T2] Data OK!"); Log.Information("[T2] Data OK!");
var clientState = Service<ClientState>.Set(); using (Timings.Start("CS Init"))
Log.Information("[T2] CS OK!"); {
Service<ClientState>.Set();
Log.Information("[T2] CS OK!");
}
var localization = Service<Localization>.Set(new Localization(Path.Combine(this.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_")); var localization = Service<Localization>.Set(new Localization(Path.Combine(this.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"));
if (!string.IsNullOrEmpty(configuration.LanguageOverride)) if (!string.IsNullOrEmpty(configuration.LanguageOverride))
@ -214,14 +220,23 @@ namespace Dalamud
Log.Information("[T2] LOC OK!"); Log.Information("[T2] LOC OK!");
// This is enabled in ImGuiScene setup // This is enabled in ImGuiScene setup
Service<DalamudIME>.Set(); using (Timings.Start("IME Init"))
Log.Information("[T2] IME OK!"); {
Service<DalamudIME>.Set();
Log.Information("[T2] IME OK!");
}
Service<InterfaceManager>.Set().Enable(); using (Timings.Start("IM Enable"))
Log.Information("[T2] IM OK!"); {
Service<InterfaceManager>.Set().Enable();
Log.Information("[T2] IM OK!");
}
Service<GameFontManager>.Set(); using (Timings.Start("GFM Init"))
Log.Information("[T2] GFM OK!"); {
Service<GameFontManager>.Set();
Log.Information("[T2] GFM OK!");
}
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete
Service<SeStringManager>.Set(); Service<SeStringManager>.Set();
@ -229,27 +244,30 @@ namespace Dalamud
Log.Information("[T2] SeString OK!"); Log.Information("[T2] SeString OK!");
// Initialize managers. Basically handlers for the logic using (Timings.Start("CM Init"))
Service<CommandManager>.Set(); {
Service<CommandManager>.Set();
Service<DalamudCommands>.Set().SetupCommands(); Service<DalamudCommands>.Set().SetupCommands();
Log.Information("[T2] CM OK!");
Log.Information("[T2] CM OK!"); }
Service<ChatHandlers>.Set(); Service<ChatHandlers>.Set();
Log.Information("[T2] CH OK!"); Log.Information("[T2] CH OK!");
clientState.Enable(); using (Timings.Start("CS Enable"))
Log.Information("[T2] CS ENABLE!"); {
Service<ClientState>.Get().Enable();
Log.Information("[T2] CS ENABLE!");
}
Service<DalamudAtkTweaks>.Set().Enable(); Service<DalamudAtkTweaks>.Set().Enable();
Log.Information("[T2] ATKTWEAKS ENABLE!");
Log.Information("[T2] Load complete!"); Log.Information("[T2] Load complete!");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Tier 2 load failed."); Log.Error(ex, "Tier 2 load failed");
this.Unload(); this.Unload();
return false; return false;
} }
@ -308,17 +326,17 @@ namespace Dalamud
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Plugin load failed."); Log.Error(ex, "Plugin load failed");
} }
Troubleshooting.LogTroubleshooting(); Troubleshooting.LogTroubleshooting();
Log.Information("Dalamud is ready."); Log.Information("Dalamud is ready");
Timings.Event("Dalamud ready"); Timings.Event("Dalamud ready");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Tier 3 load failed."); Log.Error(ex, "Tier 3 load failed");
this.Unload(); this.Unload();
return false; return false;

View file

@ -9,6 +9,7 @@ using Dalamud.Interface.Internal;
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.IoC.Internal; using Dalamud.IoC.Internal;
using Dalamud.Utility; using Dalamud.Utility;
using Dalamud.Utility.Timing;
using ImGuiScene; using ImGuiScene;
using JetBrains.Annotations; using JetBrains.Annotations;
using Lumina; using Lumina;
@ -298,25 +299,32 @@ namespace Dalamud.Data
Log.Verbose("Loaded {0} ClientOpCodes.", clientOpCodeDict.Count); Log.Verbose("Loaded {0} ClientOpCodes.", clientOpCodeDict.Count);
var luminaOptions = new LuminaOptions using (Timings.Start("Lumina Init"))
{ {
CacheFileResources = true, var luminaOptions = new LuminaOptions
{
CacheFileResources = true,
#if DEBUG #if DEBUG
PanicOnSheetChecksumMismatch = true, PanicOnSheetChecksumMismatch = true,
#else #else
PanicOnSheetChecksumMismatch = false, PanicOnSheetChecksumMismatch = false,
#endif #endif
DefaultExcelLanguage = this.Language.ToLumina(), DefaultExcelLanguage = this.Language.ToLumina(),
}; };
var processModule = Process.GetCurrentProcess().MainModule; var processModule = Process.GetCurrentProcess().MainModule;
if (processModule != null) if (processModule != null)
{ {
this.GameData = new GameData(Path.Combine(Path.GetDirectoryName(processModule.FileName), "sqpack"), luminaOptions); this.GameData = new GameData(Path.Combine(Path.GetDirectoryName(processModule.FileName), "sqpack"), luminaOptions);
}
else
{
throw new Exception("Could not main module.");
}
Log.Information("Lumina is ready: {0}", this.GameData.DataPath);
} }
Log.Information("Lumina is ready: {0}", this.GameData.DataPath);
this.IsDataReady = true; this.IsDataReady = true;
this.luminaCancellationTokenSource = new(); this.luminaCancellationTokenSource = new();