Browse Source

Added stopwatch timing for certain sections of initialization

pull/94/head
Anairkoen Schno 3 years ago
parent
commit
c8993c2c27
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
2 changed files with 20 additions and 4 deletions
  1. +11
    -0
      IPA.Loader/Loader/PluginLoader.cs
  2. +9
    -4
      IPA.Loader/Loader/PluginManager.cs

+ 11
- 0
IPA.Loader/Loader/PluginLoader.cs View File

@ -16,6 +16,7 @@ using Version = SemVer.Version;
using SemVer; using SemVer;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using HarmonyLib; using HarmonyLib;
using System.Diagnostics;
#if NET4 #if NET4
using Task = System.Threading.Tasks.Task; using Task = System.Threading.Tasks.Task;
using TaskEx = System.Threading.Tasks.Task; using TaskEx = System.Threading.Tasks.Task;
@ -42,8 +43,14 @@ namespace IPA.Loader
{ {
YeetIfNeeded(); YeetIfNeeded();
var sw = Stopwatch.StartNew();
LoadMetadata(); LoadMetadata();
sw.Stop();
Logger.loader.Info($"Loading metadata took {sw.Elapsed}");
sw.Reset();
// old loader system // old loader system
#if false #if false
Resolve(); Resolve();
@ -55,10 +62,14 @@ namespace IPA.Loader
ResolveDependencies(); ResolveDependencies();
#endif #endif
sw.Start();
// Features contribute to load order considerations // Features contribute to load order considerations
InitFeatures(); InitFeatures();
DoOrderResolution(); DoOrderResolution();
sw.Stop();
Logger.loader.Info($"Calculating load order took {sw.Elapsed}");
}); });
internal static void YeetIfNeeded() internal static void YeetIfNeeded()


+ 9
- 4
IPA.Loader/Loader/PluginManager.cs View File

@ -15,6 +15,7 @@ using Logger = IPA.Logging.Logger;
using System.Threading.Tasks; using System.Threading.Tasks;
using IPA.Utilities.Async; using IPA.Utilities.Async;
using IPA.Loader.Features; using IPA.Loader.Features;
using System.Diagnostics;
#if NET4 #if NET4
using TaskEx = System.Threading.Tasks.Task; using TaskEx = System.Threading.Tasks.Task;
using TaskEx6 = System.Threading.Tasks.Task; using TaskEx6 = System.Threading.Tasks.Task;
@ -353,14 +354,15 @@ namespace IPA.Loader
if (!Directory.Exists(pluginDirectory)) return; if (!Directory.Exists(pluginDirectory)) return;
var sw = Stopwatch.StartNew();
// initialize BSIPA plugins first // initialize BSIPA plugins first
_bsPlugins.AddRange(PluginLoader.LoadPlugins()); _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<string>(PluginLoader.PluginsMetadata.Select(m => m.File.FullName));
var ignoredPaths = new HashSet<string>(PluginLoader.ignoredPlugins.Select(m => m.Key.File.FullName)
.Concat(PluginLoader.ignoredPlugins.SelectMany(m => m.Key.AssociatedFiles.Select(f => f.FullName))));
var disabledPaths = new HashSet<string>(DisabledPlugins.Select(m => m.File.FullName).ToList());
//Copy plugins to .cache //Copy plugins to .cache
string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll"); string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll");
@ -438,6 +440,8 @@ namespace IPA.Loader
} }
} }
sw.Stop();
Logger.log.Info(exeName); Logger.log.Info(exeName);
Logger.log.Info($"Running on Unity {Application.unityVersion}"); Logger.log.Info($"Running on Unity {Application.unityVersion}");
Logger.log.Info($"Game version {UnityGame.GameVersion}"); Logger.log.Info($"Game version {UnityGame.GameVersion}");
@ -457,6 +461,7 @@ namespace IPA.Loader
} }
Logger.log.Info("-----------------------------"); Logger.log.Info("-----------------------------");
} }
Logger.log.Info($"Initializing plugins took {sw.Elapsed}");
} }
private static IEnumerable<Old.IPlugin> LoadPluginsFromFile(string file) private static IEnumerable<Old.IPlugin> LoadPluginsFromFile(string file)


Loading…
Cancel
Save