Example #1
0
        public static (IList <string>, IList <string>) GetFrameStats()
        {
            var sb           = new StringBuilder();
            var descriptions = new List <string>();
            var results      = new List <string>();

            lock (SyncRoot)
            {
                foreach (var kvp in FrameTimes.OrderBy(x => x.Key))
                {
                    sb.Append($"Avg/frame: {(float)kvp.Value.Total / (10000 * _frameCount):F3}");
                    sb.Append($" Min: {(float)kvp.Value.Min / 10000:F3}");
                    sb.Append($" Max: {(float)kvp.Value.Max / 10000:F3}");
                    sb.Append($" F:{kvp.Value.Fast / 10000:F3}");
                    sb.Append($" Avg/call: {(float)kvp.Value.Total / (10000 * kvp.Value.Count):F3}");
                    sb.Append($" Calls/Frame: {(float)kvp.Value.Count / _frameCount:F3}");
                    sb.Append($" Total: {kvp.Value.Total / 10000}");
                    sb.Append($" Count: {kvp.Value.Count}");
                    descriptions.Add(kvp.Key);
                    results.Add(sb.ToString());
                    sb.Clear();
                }
            }

            return(descriptions, results);
        }
Example #2
0
 public static void Clear()
 {
     lock (SyncRoot)
     {
         FrameTimes.Clear();
         _frameCount = 0;
     }
 }
Example #3
0
            public void Dispose()
            {
                lock (SyncRoot)
                {
                    long ticks = _stopwatch.ElapsedTicks;
                    if (!FrameTimes.ContainsKey(_name))
                    {
                        FrameTimes[_name] = new Stats {
                            Fast = ticks
                        }
                    }
                    ;

                    var stats = FrameTimes[_name];
                    stats.AddTicks(ticks);
                }
            }
        }
Example #4
0
        public static void BeginFrame()
        {
            if (_frameCount == 1)
            {
                StartupEvent("First frame finished"); // Last startup event to be emitted
            }
            _frameCount++;
            foreach (var key in FrameCounters.Keys.ToList())
            {
                var count = FrameCounters[key];
                if (!FrameTimes.ContainsKey(key))
                {
                    FrameTimes[key] = new Stats {
                        Fast = count * 10000
                    }
                }
                ;

                var stats = FrameTimes[key];
                stats.AddMs(count);

                FrameCounters[key] = 0;
            }
        }