1 using System.Collections.Generic;
2 using System.Diagnostics;
9 private readonly
object mutex =
new object();
16 private readonly Queue<double> sampleBuffer =
new Queue<double>();
24 private readonly Dictionary<string, Queue<long>> elapsedTicks =
new Dictionary<string, Queue<long>>();
25 private readonly Dictionary<string, long> avgTicksPerFrame =
new Dictionary<string, long>();
28 internal Graph UpdateTimeGraph =
new Graph(500), DrawTimeGraph =
new Graph(500);
31 private readonly List<string> tempSavedIdentifiers =
new List<string>();
38 tempSavedIdentifiers.Clear();
39 tempSavedIdentifiers.AddRange(avgTicksPerFrame.Keys);
41 return tempSavedIdentifiers;
49 if (!elapsedTicks.ContainsKey(identifier)) { elapsedTicks.Add(identifier,
new Queue<long>()); }
50 elapsedTicks[identifier].Enqueue(ticks);
54 elapsedTicks[identifier].Dequeue();
55 avgTicksPerFrame[identifier] = (long)elapsedTicks[identifier].Average(i => i);
62 long ticksPerFrame = 0;
65 avgTicksPerFrame.TryGetValue(identifier, out ticksPerFrame);
67 return ticksPerFrame * 1000.0f / Stopwatch.Frequency;
72 if (deltaTime == 0.0f) {
return false; }
80 sampleBuffer.Dequeue();