示例#1
0
        // public static void Measure(string name, DateTime startTime, GameContext gameContext) =>
        //     Measure(name, startTime, GetProfilingComponent(gameContext));
        public static void Measure(string name, DateTime startTime, ProfilingComponent MyProfiler, string tag = "", bool countToTagTimeOnly = false)
        {
            var diff     = DateTime.Now - startTime;
            var duration = diff.Milliseconds;

            if (!countToTagTimeOnly)
            {
                MyProfiler.ProfilerMilliseconds += duration;
            }

            if (MyProfiler.Tags == null)
            {
                MyProfiler.Tags = new Dictionary <string, long>();
            }

            if (tag.Length > 0)
            {
                if (!MyProfiler.Tags.ContainsKey(tag))
                {
                    MyProfiler.Tags[tag] = 0;
                }

                MyProfiler.Tags[tag] += duration;
            }

            if (duration > 0)
            {
                MyProfiler.MyProfiler.AppendLine($@"{name}: {duration}ms");
            }
        }
示例#2
0
 public static void MeasureMarkup(ProfilingComponent MyProfiler, string text = "---------------------")
 {
     MyProfiler.MyProfiler.AppendLine(text);
 }