public void Stop(PerformanceTimer timer) { recursionCount--; PerformanceTimerDisplayData timerData = timeDisplayData[timer.Name]; timerData.ActiveCount--; if (timerData.ActiveCount == 0) { timerData.endTimeMs = UiThread.CurrentTimerMs; string outputText = "{0:0.00} ms - {1}".FormatWith(timerData.ElapsedMs, timer.Name); if (timerData.TotalCount > 1) { outputText += " ({0})".FormatWith(timerData.TotalCount); } if (recursionCount > 0) { if (recursionCount == 1) { outputText = "|_" + outputText; } else { outputText = new string(' ', recursionCount - 1) + "|_" + outputText; } } // TODO: put this is a pre-draw variable to set next time we are going to draw // Doing it here causes an invalidate and endless drawing. timerData.widget.Text = outputText; } }
public PerformancePannel(string name) : base(FlowDirection.TopToBottom) { this.Name = name; Margin = new BorderDouble(5); Padding = new BorderDouble(3); VAnchor |= VAnchor.ParentTop; if (pannels == null) { pannels = new PerformanceDisplayWidget(); pannels.Selectable = false; pannels.HAnchor |= HAnchor.ParentLeft; pannels.VAnchor |= VAnchor.ParentTop; pannels.Visible = false; // start out not visible //pannels.Visible = false; // start out not visible if (true) // only add this when doing testing { UiThread.RunOnIdle(() => { if (PerformanceTimer.GetParentWindowFunction != null) { GuiWidget parentWindow = PerformanceTimer.GetParentWindowFunction(); parentWindow.AddChild(pannels); #if DEBUG parentWindow.KeyDown += ParentWindow_KeyDown; parentWindow.MouseDownInBounds += ParentWindow_MouseDown; #endif } }); } } // add in the column title { TextWidget titleWidget = new TextWidget(name, pointSize: 14) { BackgroundColor = new RGBA_Bytes(), TextColor = new RGBA_Bytes(20, 120, 20), }; titleWidget.Printer.DrawFromHintedCache = true; AddChild(titleWidget); } AddChild(topToBottom); pannels.AddChild(this); BackgroundColor = new RGBA_Bytes(RGBA_Bytes.White, 180); }
internal void Start(PerformanceTimer timer) { if (!timeDisplayData.ContainsKey(timer.Name)) { PerformanceTimerDisplayData newTimerData = new PerformanceTimerDisplayData(timer.Name) { widget = new TextWidget("waiting") { AutoExpandBoundsToText = true, TextColor = new Color(120, 20, 20), HAnchor = HAnchor.Left, } }; newTimerData.widget.Printer.DrawFromHintedCache = true; timeDisplayData.Add(timer.Name, newTimerData); topToBottom.AddChild(newTimerData.widget); } if (recursionCount == 0) { foreach (KeyValuePair <string, PerformanceTimerDisplayData> displayItemKeyValue in timeDisplayData) { displayItemKeyValue.Value.drawOrder = int.MaxValue; } } PerformanceTimerDisplayData timerData = timeDisplayData[timer.Name]; if (timerData.ActiveCount == 0) { if (timerData.startTimeMs == 0) { timerData.startTimeMs = UiThread.CurrentTimerMs; } else // Add on to the time we have tracked so far. We have not show any time yet. { long timeSoFar = timerData.endTimeMs - timerData.startTimeMs; timerData.startTimeMs = UiThread.CurrentTimerMs - timeSoFar; } timerData.drawOrder = recursionCount; } timerData.ActiveCount++; timerData.TotalCount++; recursionCount++; }
internal void Start(PerformanceTimer timer) { if (!timeDisplayData.ContainsKey(timer.Name)) { PerformanceTimerDisplayData newTimerData = new PerformanceTimerDisplayData(timer.Name) { widget = new TextWidget("waiting") { AutoExpandBoundsToText = true, TextColor = new RGBA_Bytes(120, 20, 20), HAnchor = HAnchor.ParentLeft, } }; newTimerData.widget.Printer.DrawFromHintedCache = true; timeDisplayData.Add(timer.Name, newTimerData); topToBottom.AddChild(newTimerData.widget); } if (recursionCount == 0) { foreach (KeyValuePair<string, PerformanceTimerDisplayData> displayItemKeyValue in timeDisplayData) { displayItemKeyValue.Value.drawOrder = int.MaxValue; } } PerformanceTimerDisplayData timerData = timeDisplayData[timer.Name]; if (timerData.ActiveCount == 0) { if (timerData.startTimeMs == 0) { timerData.startTimeMs = UiThread.CurrentTimerMs; } else // Add on to the time we have tracked so far. We have not show any time yet. { long timeSoFar = timerData.endTimeMs - timerData.startTimeMs; timerData.startTimeMs = UiThread.CurrentTimerMs - timeSoFar; } timerData.drawOrder = recursionCount; } timerData.ActiveCount++; timerData.TotalCount++; recursionCount++; }
public void Stop(PerformanceTimer timer) { recursionCount--; PerformanceTimerDisplayData timerData = timeDisplayData[timer.Name]; timerData.ActiveCount--; if (timerData.ActiveCount == 0) { timerData.endTimeMs = UiThread.CurrentTimerMs; string outputText = "{0:0.00} ms - {1}".FormatWith(timerData.ElapsedMs, timer.Name); if (timerData.TotalCount > 1) { outputText += " ({0})".FormatWith(timerData.TotalCount); } if (recursionCount > 0) { if (recursionCount == 1) { outputText = "|_" + outputText; } else { outputText = new string(' ', recursionCount - 1) + "|_" + outputText; } } // TODO: put this is a pre-draw variable to set next time we are going to draw // Doing it here causes an invalidate and endlelss drawing. timerData.widget.Text = outputText; } }