Add better time logging to reflection init

This commit is contained in:
Sinai 2021-06-01 16:00:18 +10:00
parent a5f56cf5a3
commit c4fa0d6bcd
2 changed files with 10 additions and 8 deletions

View File

@ -16,6 +16,7 @@ using CppType = Il2CppSystem.Type;
using BF = System.Reflection.BindingFlags; using BF = System.Reflection.BindingFlags;
using UnityExplorer.Core.Config; using UnityExplorer.Core.Config;
using UnhollowerBaseLib.Attributes; using UnhollowerBaseLib.Attributes;
using UnityEngine;
namespace UnityExplorer namespace UnityExplorer
{ {
@ -25,10 +26,15 @@ namespace UnityExplorer
{ {
base.Initialize(); base.Initialize();
float start = Time.realtimeSinceStartup;
TryLoadGameModules(); TryLoadGameModules();
ExplorerCore.Log($"Loaded Unhollowed modules in {Time.realtimeSinceStartup - start} seconds");
start = Time.realtimeSinceStartup;
BuildDeobfuscationCache(); BuildDeobfuscationCache();
OnTypeLoaded += TryCacheDeobfuscatedType; OnTypeLoaded += TryCacheDeobfuscatedType;
ExplorerCore.Log($"Setup IL2CPP reflection in {Time.realtimeSinceStartup - start} seconds, " +
$"deobfuscated types count: {DeobfuscatedTypes.Count}");
} }
#region IL2CPP Extern and pointers #region IL2CPP Extern and pointers
@ -67,19 +73,11 @@ namespace UnityExplorer
private static void BuildDeobfuscationCache() private static void BuildDeobfuscationCache()
{ {
float start = UnityEngine.Time.realtimeSinceStartup;
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{ {
foreach (var type in asm.TryGetTypes()) foreach (var type in asm.TryGetTypes())
TryCacheDeobfuscatedType(type); TryCacheDeobfuscatedType(type);
} }
if (DeobfuscatedTypes.Count > 0)
{
ExplorerCore.Log($"Built deobfuscation cache in {UnityEngine.Time.realtimeSinceStartup - start} seconds, " +
$"initial count: {DeobfuscatedTypes.Count} ");
}
} }
private static void TryCacheDeobfuscatedType(Type type) private static void TryCacheDeobfuscatedType(Type type)

View File

@ -65,10 +65,14 @@ namespace UnityExplorer
private static void SetupTypeCache() private static void SetupTypeCache()
{ {
float start = Time.realtimeSinceStartup;
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
CacheTypes(asm); CacheTypes(asm);
AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded; AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded;
ExplorerCore.Log($"Cached AppDomain assemblies in {Time.realtimeSinceStartup - start} seconds");
} }
private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args) private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)