From c8993c2c2773cdccdcf2f5567adaadfdc01d9322 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 28 Mar 2021 19:22:24 -0500 Subject: [PATCH] Added stopwatch timing for certain sections of initialization --- IPA.Loader/Loader/PluginLoader.cs | 11 +++++++++++ IPA.Loader/Loader/PluginManager.cs | 13 +++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index e9993cf3..feb72462 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -16,6 +16,7 @@ using Version = SemVer.Version; using SemVer; using System.Diagnostics.CodeAnalysis; using HarmonyLib; +using System.Diagnostics; #if NET4 using Task = System.Threading.Tasks.Task; using TaskEx = System.Threading.Tasks.Task; @@ -42,8 +43,14 @@ namespace IPA.Loader { YeetIfNeeded(); + var sw = Stopwatch.StartNew(); + LoadMetadata(); + sw.Stop(); + Logger.loader.Info($"Loading metadata took {sw.Elapsed}"); + sw.Reset(); + // old loader system #if false Resolve(); @@ -55,10 +62,14 @@ namespace IPA.Loader ResolveDependencies(); #endif + sw.Start(); + // Features contribute to load order considerations InitFeatures(); DoOrderResolution(); + sw.Stop(); + Logger.loader.Info($"Calculating load order took {sw.Elapsed}"); }); internal static void YeetIfNeeded() diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 77634b75..06239cd4 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -15,6 +15,7 @@ using Logger = IPA.Logging.Logger; using System.Threading.Tasks; using IPA.Utilities.Async; using IPA.Loader.Features; +using System.Diagnostics; #if NET4 using TaskEx = System.Threading.Tasks.Task; using TaskEx6 = System.Threading.Tasks.Task; @@ -353,14 +354,15 @@ namespace IPA.Loader if (!Directory.Exists(pluginDirectory)) return; + var sw = Stopwatch.StartNew(); // initialize BSIPA plugins first _bsPlugins.AddRange(PluginLoader.LoadPlugins()); - var metadataPaths = PluginLoader.PluginsMetadata.Select(m => m.File.FullName).ToList(); - var ignoredPaths = PluginLoader.ignoredPlugins.Select(m => m.Key.File.FullName) - .Concat(PluginLoader.ignoredPlugins.SelectMany(m => m.Key.AssociatedFiles.Select(f => f.FullName))).ToList(); - var disabledPaths = DisabledPlugins.Select(m => m.File.FullName).ToList(); + var metadataPaths = new HashSet(PluginLoader.PluginsMetadata.Select(m => m.File.FullName)); + var ignoredPaths = new HashSet(PluginLoader.ignoredPlugins.Select(m => m.Key.File.FullName) + .Concat(PluginLoader.ignoredPlugins.SelectMany(m => m.Key.AssociatedFiles.Select(f => f.FullName)))); + var disabledPaths = new HashSet(DisabledPlugins.Select(m => m.File.FullName).ToList()); //Copy plugins to .cache string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll"); @@ -438,6 +440,8 @@ namespace IPA.Loader } } + sw.Stop(); + Logger.log.Info(exeName); Logger.log.Info($"Running on Unity {Application.unityVersion}"); Logger.log.Info($"Game version {UnityGame.GameVersion}"); @@ -457,6 +461,7 @@ namespace IPA.Loader } Logger.log.Info("-----------------------------"); } + Logger.log.Info($"Initializing plugins took {sw.Elapsed}"); } private static IEnumerable LoadPluginsFromFile(string file)