Esempio n. 1
0
        private void DoInstantiateTask(float delta)
        {
            if (mAsyncInstTransiting)
            {
                DebugUtility.LogError(LoggerTags.AssetManager, "Check the error call.");
                return;
            }
            mAsyncInstTransiting = true;
            mAsyncInstWatch.Restart();

            ProfilingUtility.BeginSample("DoInstantiateTask");
            int length = mAsyncInstAssetsInfo.Count;

            for (int i = 0; i < length; i++)
            {
                var task = mAsyncInstAssetsInfo[i];
                if (task != null && task.state == AsyncInstAssetInfo.EAsyncState.ToBeContinue)
                {
                    ProfilingUtility.BeginSample(task.ToString());
                    task.Instantiate();
                    ProfilingUtility.EndSample();
                }
                // pf warning
                if (mAsyncInstWatch.ElapsedMilliseconds >= mAsyncInstPfWarning)
                {
                    break;
                }
            }
            mAsyncInstWatch.Stop();
            ProfilingUtility.EndSample();
            mAsyncInstTransiting = false;
            CleanupInvalidTasks();
        }
Esempio n. 2
0
        public static void LoadAssemblies(bool force = false)
        {
            if (msAssemblyTypeCaches.Count > 0 && !force)
            {
                return;
            }
            msAssemblyTypeCaches.Clear();

            Assembly[] allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            if (allAssemblies == null)
            {
                return;
            }

            ProfilingUtility.BeginSample("GlobalReflectionCache.LoadAssemblies");
            foreach (Assembly assembly in allAssemblies)
            {
                if (assembly.FullName.Contains("Microsoft."))
                {
                    continue;
                }

                //DebugUtility.LogTrace(LoggerTags.Engine, "GlobalReflectionCache.CollectTypes {0}", assembly.FullName);
                ProfilingUtility.BeginSample("GlobalReflectionCache.CollectTypes_", assembly.FullName);
                GlobalReflectionCache.CollectTypes(assembly);
                ProfilingUtility.EndSample();
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 3
0
 internal void Uninitialize()
 {
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize begin all");
     ProfilingUtility.BeginSample("ModuleManager.Uninitialize");
     for (int i = mAllModules.Count - 1; i >= 0; i--)
     {
         IModuleInterface m = mAllModules[i];
         if (m.status == EModuleStatus.PostInitialize)
         {
             DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize begin : " + m.moduleName);
             ProfilingUtility.BeginSample("ModuleManager.Uninitialize_", m.moduleName);
             try
             {
                 m.Uninitialize();
             }
             catch (System.Exception ex)
             {
                 DebugUtility.LogException(ex);
             }
             m.status = EModuleStatus.Loaded;
             ProfilingUtility.EndSample();
             DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize end : " + m.moduleName);
         }
     }
     ProfilingUtility.EndSample();
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.Uninitialize end all");
 }
Esempio n. 4
0
        private static void OnEditorUpdate()
        {
            LokiEditorTime.Update();

            ProfilingUtility.BeginSample("OnLokiEditorUpdate");
            EditorUpdateInternal();
            ProfilingUtility.EndSample();
        }
Esempio n. 5
0
 public static List <Type> FindTypes(Type typeConstraint, bool allowAbstract, List <Type> caches = null)
 {
     LoadAssemblies();
     ProfilingUtility.BeginSample("GlobalReflectionCache.FindAllTypesContainsAttribute");
     foreach (var assemblyInfo in msAssemblyTypeCaches.Values)
     {
         caches = assemblyInfo.FindTypes(typeConstraint, allowAbstract, caches);
     }
     ProfilingUtility.EndSample();
     return(caches);
 }
Esempio n. 6
0
        public static T FindRecursion <T>(this Transform transform, string name, bool includeSelf = false) where T : Component
        {
            if (transform == null)
            {
                return(null);
            }

            ProfilingUtility.BeginSample("FindComponentInRecursion_", transform.name);
            var target = FindRecursionInternal <T>(transform, name, includeSelf);

            ProfilingUtility.EndSample();
            return(target);
        }
Esempio n. 7
0
        public static T NewObject <T>(T original, Transform parent, bool worldPositionStays) where T : Object
        {
            if (original == null)
            {
                return(null);
            }

            ProfilingUtility.BeginSample("UObject.NewObject_", original.name);
            T result = Instantiate <T>(original, parent, worldPositionStays);

            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 8
0
        public static T NewObject <T>(T original, Vector3 position, Quaternion rotation) where T : Object
        {
            if (original == null)
            {
                return(null);
            }

            ProfilingUtility.BeginSample("UObject.NewObject_", original.name);
            T result = Instantiate <T>(original, position, rotation);

            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 9
0
        public static Object NewObject(Object original)
        {
            if (original == null)
            {
                return(null);
            }

            ProfilingUtility.BeginSample("UObject.NewObject_", original.name);
            Object result = Instantiate(original);

            ProfilingUtility.EndSample();

            return(result);
        }
Esempio n. 10
0
        public static Object NewObject(Object original, Vector3 position, Quaternion rotation, Transform parent)
        {
            if (original == null)
            {
                return(null);
            }

            ProfilingUtility.BeginSample("UObject.NewObject_", original.name);
            Object result = Instantiate(original, position, rotation, parent);

            ProfilingUtility.EndSample();

            return(result);
        }
Esempio n. 11
0
        public static void CollectTypes(Assembly assembly)
        {
            ProfilingUtility.BeginSample("GlobalReflectionCache.CollectTypes_", assembly.FullName);

            ReflectionAssemblyInfo typesCache;

            if (!msAssemblyTypeCaches.TryGetValue(assembly, out typesCache))
            {
                typesCache = new ReflectionAssemblyInfo(assembly);
                msAssemblyTypeCaches.Add(assembly, typesCache);
                typesCache.Load();
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 12
0
        public void AbandonModule(string moduleName)
        {
            ProfilingUtility.BeginSample("ModuleManager.AbandonModule_", moduleName);
            IModuleInterface m = GetModule(moduleName);

            if (m != null)
            {
                if (m.status != EModuleStatus.None)
                {
                    m.ShutdownModule(EModuleShutdownReason.Runtime);
                    m.status = EModuleStatus.None;
                }
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 13
0
        /// <summary>
        /// Get components in children  (TTargetComponent, TTargetComponentAsResult)
        /// </summary>
        /// <typeparam name="TComponent">The target component type</typeparam>
        /// <param name="transform">start from here</param>
        /// <param name="includeInactive">include inactive gameObject</param>
        /// <param name="stopType">The stop condition component type</param>
        /// <param name="result">the result</param>
        /// <typeparam name="TComponent"></typeparam>
        public static void GetComponentsInChildren <TComponent, TResult>(this Transform transform, bool includeInactive, EComponentSearchOption searchOption, Type stopType, List <TResult> result)
            where TComponent : Component, TResult
        {
            ProfilingUtility.BeginSample("GetComponentsInChildren_" + transform.name);
            bool continueToGet = true;

            if ((searchOption & EComponentSearchOption.SearchThis) != 0)
            {
                continueToGet = GetComponentsInternalSelf <TComponent, TResult>(transform, searchOption, stopType, result, true);
            }
            if (continueToGet)
            {
                GetComponentsInternal <TComponent, TResult>(transform, includeInactive, searchOption, stopType, result);
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 14
0
 public List <MethodInfo> FindMethods(Predicate <MethodInfo> predicate, List <MethodInfo> caches = null)
 {
     ProfilingUtility.BeginSample("GlobalReflectionCache.FindMethods");
     if (caches == null)
     {
         caches = new List <MethodInfo>();
     }
     foreach (var m in methodInfos)
     {
         if (predicate(m))
         {
             caches.Add(m);
         }
     }
     ProfilingUtility.EndSample();
     return(caches);
 }
Esempio n. 15
0
        public ReflectionTypeInfo FindType(string typeName, bool isFullName)
        {
            ReflectionTypeInfo result = default;

            ProfilingUtility.BeginSample("ReflectionAssemblyInfo.FindType");
            foreach (var typeInfo in mTypesInfo.Values)
            {
                if ((!isFullName && typeInfo.type.Name == typeName) ||
                    (isFullName && typeInfo.type.FullName == typeName))
                {
                    result = typeInfo;
                    break;
                }
            }
            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 16
0
        public static Type FindType(Type typeConstraint, bool allowAbstract)
        {
            Type result = null;

            LoadAssemblies();
            ProfilingUtility.BeginSample("GlobalReflectionCache.FindType");
            foreach (var assemblyInfo in msAssemblyTypeCaches.Values)
            {
                result = assemblyInfo.FindType(typeConstraint, allowAbstract);
                if (result != null)
                {
                    break;
                }
            }
            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 17
0
 public List <PropertyInfo> FindProperties(Predicate <PropertyInfo> predicate, List <PropertyInfo> caches = null)
 {
     ProfilingUtility.BeginSample("GlobalReflectionCache.FindProperties");
     if (caches == null)
     {
         caches = new List <PropertyInfo>();
     }
     foreach (var property in propertyInfos)
     {
         if (predicate(property))
         {
             caches.Add(property);
         }
     }
     ProfilingUtility.EndSample();
     return(caches);
 }
Esempio n. 18
0
        public static Transform FindUnique(this Transform transform, string name, StringComparison comparison = StringComparison.Ordinal)
        {
            ProfilingUtility.BeginSample("FindUnique_" + name);
            Transform result = null;

            if (IsRootJoint(name))
            {
                result = transform;
            }
            else
            {
                result = transform.FindUniqueInternal(name, comparison);
            }
            ProfilingUtility.EndSample();

            return(result);
        }
Esempio n. 19
0
 public List <FieldInfo> FindFields(Predicate <FieldInfo> predicate, List <FieldInfo> caches = null)
 {
     ProfilingUtility.BeginSample("GlobalReflectionCache.FindFields");
     if (caches == null)
     {
         caches = new List <FieldInfo>();
     }
     foreach (var field in fieldInfos)
     {
         if (predicate(field))
         {
             caches.Add(field);
         }
     }
     ProfilingUtility.EndSample();
     return(caches);
 }
Esempio n. 20
0
        private void DoUpdate(float deltaTime)
        {
            mIsTransiting = true;

            int timerCount = mRunningTimers.Count;

            for (int idx = 0; idx < timerCount; ++idx)
            {
                Timer timer = mRunningTimers[idx];
                if (timer.isValid && !timer.pause)
                {
                    bool  exec     = false;
                    float duration = timer.duration - deltaTime;
                    if (duration <= 0.0f)
                    {
                        exec     = true;
                        duration = timer.rate;
                        if (timer.loopCount > 0)
                        {
                            timer.loopCount -= 1;
                        }
                    }
                    timer.duration      = duration;
                    mRunningTimers[idx] = timer;

                    if (exec)
                    {
                        ProfilingUtility.BeginSample("TimerManager.OnUpdate.ExecTimerCallback");
                        try
                        {
                            timer.Callback();
                        }
                        catch (Exception ex)
                        {
                            DebugUtility.LogException(ex);
                        }
                        ProfilingUtility.EndSample();
                    }
                }
            }

            mIsTransiting = false;
        }
Esempio n. 21
0
        public void OnUpdate(float deltaTime)
        {
            if (mIsTransiting)
            {
                return;
            }

            ProfilingUtility.BeginSample("TimerManager.OnUpdate");

            ProfilingUtility.BeginSample("TimerManager.DoUpdate");
            DoUpdate(deltaTime);
            ProfilingUtility.EndSample();

            ProfilingUtility.BeginSample("TimerManager.ClearInvalidTimers");
            ClearInvalidTimers();
            ProfilingUtility.EndSample();

            ProfilingUtility.EndSample();
        }
Esempio n. 22
0
        public void PauseTimer(TimerHandler handler)
        {
            if (!handler.IsValid)
            {
                return;
            }
            ProfilingUtility.BeginSample("TimerManager.PauseTimer");
            int timerCount = mRunningTimers.Count;

            for (int idx = 0; idx < timerCount; ++idx)
            {
                Timer timer = mRunningTimers[idx];
                if (timer.handler == handler)
                {
                    timer.pause         = true;
                    mRunningTimers[idx] = timer;
                    break;
                }
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 23
0
        public Type FindType(Type typeConstraint, bool allowAbstract)
        {
            Type result = null;

            ProfilingUtility.BeginSample("ReflectionAssemblyInfo.FindType");
            foreach (var typeInfo in mTypesInfo.Values)
            {
                if (typeInfo.type.IsAbstract && !allowAbstract)
                {
                    continue;
                }

                if (typeInfo.type.IsCompatibleWith(typeConstraint))
                {
                    result = typeInfo.type;
                    break;
                }
            }
            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 24
0
        public Type FindType <TAttribute>(bool allowAbstract) where TAttribute : Attribute
        {
            Type result = null;

            ProfilingUtility.BeginSample("ReflectionAssemblyInfo.FindType");
            foreach (var typeInfo in mTypesInfo.Values)
            {
                if (typeInfo.type.IsAbstract && !allowAbstract)
                {
                    continue;
                }

                if (typeInfo.GetCustomAttribute <TAttribute>() != null)
                {
                    result = typeInfo.type;
                    break;
                }
            }
            ProfilingUtility.EndSample();
            return(result);
        }
Esempio n. 25
0
 internal void OnLateUpdate()
 {
     ProfilingUtility.BeginSample("ModuleManager.LateUpdate");
     foreach (var m in mAllModules)
     {
         if (m.status == EModuleStatus.PostInitialize)
         {
             ProfilingUtility.BeginSample("ModuleManager.LateUpdate_", m.moduleName);
             try
             {
                 m.OnLateUpdate();
             }
             catch (System.Exception ex)
             {
                 DebugUtility.LogException(ex);
             }
             ProfilingUtility.EndSample();
         }
     }
     ProfilingUtility.EndSample();
 }
Esempio n. 26
0
        public List <Type> FindTypes <TAttribute>(bool allowAbstract, List <Type> caches = null) where TAttribute : Attribute
        {
            ProfilingUtility.BeginSample("ReflectionAssemblyInfo.FindTypes");
            foreach (var typeInfo in mTypesInfo.Values)
            {
                if (typeInfo.type.IsAbstract && !allowAbstract)
                {
                    continue;
                }

                if (typeInfo.GetCustomAttribute <TAttribute>() != null)
                {
                    if (caches == null)
                    {
                        caches = new List <Type>();
                    }
                    caches.Add(typeInfo.type);
                }
            }
            ProfilingUtility.EndSample();
            return(caches);
        }
Esempio n. 27
0
        public List <Type> FindTypes(Type typeConstraint, bool allowAbstract, List <Type> caches = null)
        {
            ProfilingUtility.BeginSample("ReflectionAssemblyInfo.FindTypes");
            foreach (var typeInfo in mTypesInfo.Values)
            {
                if (typeInfo.type.IsAbstract && !allowAbstract)
                {
                    continue;
                }

                if (typeInfo.type.IsCompatibleWith(typeConstraint))
                {
                    if (caches == null)
                    {
                        caches = new List <Type>();
                    }

                    caches.Add(typeInfo.type);
                }
            }
            ProfilingUtility.EndSample();
            return(caches);
        }
Esempio n. 28
0
 internal void OnApplicationQuit()
 {
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit begin all");
     ProfilingUtility.BeginSample("ModuleManager.OnApplicationQuit");
     for (int i = mAllModules.Count - 1; i >= 0; i--)
     {
         IModuleInterface m = mAllModules[i];
         DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit begin : " + m.moduleName);
         ProfilingUtility.BeginSample("ModuleManager.OnApplicationQuit_", m.moduleName);
         try
         {
             m.OnApplicationQuit();
         }
         catch (System.Exception ex)
         {
             DebugUtility.LogException(ex);
         }
         ProfilingUtility.EndSample();
         DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit end : " + m.moduleName);
     }
     ProfilingUtility.EndSample();
     DebugUtility.Log(LoggerTags.Module, "ModuleManager.OnApplicationQuit end all");
 }
Esempio n. 29
0
        public void StopTimer(ref TimerHandler handler)
        {
            if (!handler.IsValid)
            {
                return;
            }

            ProfilingUtility.BeginSample("TimerManager.StopTimer");
            int timerCount = mRunningTimers.Count;

            for (int idx = 0; idx < timerCount; ++idx)
            {
                Timer timer = mRunningTimers[idx];
                if (timer.handler == handler)
                {
                    handler.SetExpired();
                    timer.pause         = true;
                    timer.loopCount     = 0;
                    mRunningTimers[idx] = timer;
                    break;
                }
            }
            ProfilingUtility.EndSample();
        }
Esempio n. 30
0
 public void RegisterConsole(IConsoleObject o)
 {
     ProfilingUtility.BeginSample("RegisterConsole_", o.statID);
     DoRegister(o);
     ProfilingUtility.EndSample();
 }