/// <summary> /// End collecting a type of passing time (that was previously started). /// </summary> /// <param name="type"></param> internal void EndCollecting(FrameTimeType type) { // This can actually happen when Game.DrawFrame is recursively called. This happens when dialogs are shown (such as in the editor). if (CurrentCollectionTypeStack.Count == 0 || CurrentCollectionTypeStack.Peek() != type) { NewFrame(); return; } CurrentCollectionTypeStack.Pop(); if (!CollectedTimes.ContainsKey(type)) { CollectedTimes[type] = 0; } CollectedTimes[type] += consumeStopwatchElapsedTime(); }
private Color getColour(FrameTimeType type) { Color col = default(Color); switch (type) { default: case FrameTimeType.Update: col = Color.YellowGreen; break; case FrameTimeType.Draw: col = Color.BlueViolet; break; case FrameTimeType.SwapBuffer: col = Color.Red; break; #if DEBUG case FrameTimeType.Debug: col = Color.Yellow; break; #endif case FrameTimeType.Sleep: col = Color.DarkBlue; break; case FrameTimeType.Scheduler: col = Color.HotPink; break; case FrameTimeType.BetweenFrames: col = Color.GhostWhite; break; case FrameTimeType.Empty: col = new Color(50, 40, 40, 180); break; } return(col); }
/// <summary> /// Start collecting a type of passing time. /// </summary> internal void BeginCollecting(FrameTimeType type) { if (!timekeepingStopWatch.IsRunning) { timekeepingStopWatch.Start(); } if (CurrentCollectionTypeStack.Count > 0) { FrameTimeType t = CurrentCollectionTypeStack.Peek(); if (!CollectedTimes.ContainsKey(t)) { CollectedTimes[t] = 0; } CollectedTimes[t] += consumeStopwatchElapsedTime(); } CurrentCollectionTypeStack.Push(type); }
private int addArea(FrameTimeType frameTimeType, int currentHeight) { double elapsedMilliseconds = 0; int drawHeight = 0; if (frameTimeType == FrameTimeType.Empty) { drawHeight = currentHeight; } else if (monitor.CollectedTimes.TryGetValue(frameTimeType, out elapsedMilliseconds)) { drawHeight = (int)(elapsedMilliseconds * scale); } else { return(currentHeight); } Color col = getColour(frameTimeType); for (int i = currentHeight - 1; i >= 0; --i) { if (drawHeight-- == 0) { break; } int index = i * 4; textureData[index] = col.R; textureData[index + 1] = col.G; textureData[index + 2] = col.B; textureData[index + 3] = frameTimeType == FrameTimeType.Empty ? (byte)(col.A * (1 - (int)((i * 4) / HEIGHT) / 8f)) : col.A; currentHeight--; } return(currentHeight); }