Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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++;
        }
Esempio n. 3
0
 static int SortOnDrawOrder(PerformanceTimerDisplayData x, PerformanceTimerDisplayData y)
 {
     return(x.drawOrder.CompareTo(y.drawOrder));
 }
Esempio n. 4
0
		static int SortOnDrawOrder(PerformanceTimerDisplayData x, PerformanceTimerDisplayData y)
		{
			return x.drawOrder.CompareTo(y.drawOrder);
		}
Esempio n. 5
0
		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++;
		}