Esempio n. 1
0
        /// <summary>
        /// Creates a new step information on the same level as before
        /// </summary>
        /// <param name="step"></param>
        public static void NextStage(string step)
        {
#if LEAK_TRACE
            EngineStageInformation parent = _current?.Parent;

            EngineStageInformation cur = _current;

            ChangeStage(step, true);  //Change out the step
            _current.Parent = parent; //Set it up to be the substep on the same level
            if (parent == null)
            {
                _informationCollection.Add(_current);

                if (cur != null)
                {
                    _console?.AddGraphValue((float)cur.TimeSpentInStage.TotalMilliseconds);
                }


                while (_informationCollection.Count >= MaxTraceCount)
                {
                    _informationCollection.RemoveAt(0);
                }
            }
            else
            {
                parent.SubStages.Add(_current); //If not null then we add it to the parent list of substeps
            }
#endif
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a "console-friendly" view of the Engine Stage by utilizing tabulators
        /// </summary>
        /// <param name="info">The info to represent</param>
        /// <param name="depth">The depth of the Engine Stage(Gets used for placing Tabulator characters)</param>
        /// <returns></returns>
        public static string ToConsoleText(EngineStageInformation info, int depth)
        {
            string ind = "\t";

            for (int i = 0; i < depth; i++)
            {
                ind += "\t";
            }


            string ret = info.Name + "\n";

            ret += ind + "KB Used Before: " + info.Before + "\n";
            ret += ind + "KB Used After: " + info.After + "\n";
            ret += ind + "KB Used After(post GC): " + info.AfterGarbageCollection + "\n";
            ret += ind + "Elapsed Time(MS): " + info.TimeSpentInStage.TotalMilliseconds + "\n";
            ret += ind + "Substep Count: " + info.SubStages.Count + "\n";
            ret += ind + "Substeps: \n";


            foreach (EngineStageInformation stepMemoryInformation in info.SubStages)
            {
                ret += ToConsoleText(stepMemoryInformation, depth + 1);
            }

            return(ret);
        }
Esempio n. 3
0
        /// <summary>
        /// Changes the Stage to the next stage/ or a substage
        /// </summary>
        /// <param name="name">Name of the next stage</param>
        /// <param name="finalize">If true it will end the last stage(e.g. its not a substage)</param>
        /// <returns></returns>
        private static EngineStageInformation ChangeStage(string name, bool finalize)
        {
            EngineStageInformation old = _current;

            if (finalize)
            {
                old?.FinalizeStage();
            }

            _current = new EngineStageInformation(name);
            return(old);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns to the next higher parent step(does nothing when in root)
        /// </summary>
        public static void ReturnFromSubStage()
        {
#if LEAK_TRACE
            if (_current != null)
            {
                _current.FinalizeStage();
                if (_current.Parent != null)
                {
                    _current = _current.Parent;
                }
            }
#endif
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new step information on one level deeper as before
        /// </summary>
        /// <param name="step"></param>
        public static void AddSubStage(string step)
        {
#if LEAK_TRACE
            EngineStageInformation current = _current; //Store the current step or substep
            ChangeStage(step, false);
            _current.Parent = current;                 //Set it up to be the substep on one level deeper
            if (current == null)
            {
                _informationCollection.Add(_current);

                while (_informationCollection.Count >= MaxTraceCount)
                {
                    _informationCollection.RemoveAt(0);
                }
            }
            else
            {
                current.SubStages.Add(_current); //If not null then we add it to the parent list of substeps
            }
#endif
        }