profiling thinsg

This commit is contained in:
GoaLitiuM
2021-09-16 19:00:09 +03:00
parent eff5b555ba
commit 484038c670
5 changed files with 51 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -117,7 +117,7 @@
"Transform": {
"Translation": {
"X": 0.0,
"Y": 730.0,
"Y": 248.0,
"Z": 0.0
}
},
@@ -170,9 +170,9 @@
},
"Offsets": {
"Left": 0.0,
"Right": 143.0,
"Top": -80.0,
"Bottom": 112.0
"Right": 30948.0,
"Top": -562.0,
"Bottom": 576.0
},
"Scale": {
"X": 1.0,

View File

@@ -206,10 +206,10 @@ namespace Cabrito
if (!font)
return;
Profiler.BeginEvent("ConsoleContetTextBoxDraw");
Stopwatch sw = Stopwatch.StartNew();
// Background
Profiler.BeginEvent("ConsoleContentTextBoxDraw_Background");
Color backColor = BackgroundColor;
if (IsMouseOver)
backColor = BackgroundSelectedColor;
@@ -219,17 +219,23 @@ namespace Cabrito
Color borderColor = IsFocused ? BorderSelectedColor : BorderColor;
if (borderColor.A > 0.0f)
Render2D.DrawRectangle(rect, borderColor);
Profiler.EndEvent();
Profiler.BeginEvent("ConsoleContentTextBoxDraw_FetchLines");
var lines = Console.Lines;
Profiler.EndEvent();
if (lines.Count > 0)
{
Profiler.BeginEvent("ConsoleContentTextBoxDraw_Lines");
// Apply view offset and clip mask
var textClipRectangle = new Rectangle(1, 1, Width - 2, Height - 2);
Render2D.PushClip(textClipRectangle);
Profiler.BeginEvent("ConsoleContentTextBoxDraw_CalcVisLines");
// Make sure lengthy lines are split
CalculateVisibleLines(lines, out int startLine, out int lastLine, out LineInfo[] wrappedLines);
Profiler.EndEvent();
float lineHeight = font.Height / Platform.DpiScale;
float accumHeight = wrappedLines.Length * lineHeight;
@@ -252,6 +258,7 @@ namespace Cabrito
// render selection
if (selectionActive)
{
Profiler.BeginEvent("ConsoleContentTextBoxDraw_Selection");
//float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f);
//alpha = alpha * alpha;
Color selectionColor = SelectionColor; // * alpha;
@@ -327,10 +334,13 @@ namespace Cabrito
layout.Bounds.Y += lineHeight;
}
Profiler.EndEvent();
}
// render lines
{
Profiler.BeginEvent("ConsoleContentTextBoxDraw_Lines_Render");
TextLayoutOptions layout = _layout;
layout.Bounds = rect;
layout.Bounds.Y -= accumHeight - Height;
@@ -341,6 +351,7 @@ namespace Cabrito
Render2D.DrawText(font, line, TextColor, ref layout);
layout.Bounds.Y += lineHeight;
}
Profiler.EndEvent();
}
/*if (CaretPosition > -1)
@@ -355,12 +366,13 @@ namespace Cabrito
}*/
Render2D.PopClip();
Profiler.EndEvent();
}
sw.Stop();
accumDrawTime += sw.Elapsed.TotalSeconds;
accumDrawTimes++;
Profiler.EndEvent();
}

View File

@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using FlaxEditor.Content.Settings;
using FlaxEngine;
using FlaxEngine.GUI;
namespace Cabrito
{
[ExecuteInEditMode]
@@ -88,6 +91,35 @@ namespace Cabrito
sb.Append("\nCon: " + conTime.ToString() + "ms");
sb.Append("\n" + currentRenderer);
sb.Append("\nGC memory: " + (GC.GetTotalMemory(false) / 1000000.0f).ToString() + "MB");
//sb.Append("\nUpdate profiler: " + updateProfTime.ToString() + "ms");
#if BUILD_DEVELOPMENT
var nameOffset = Marshal.OffsetOf(typeof(ProfilerCPU.Event), "Name0");
foreach (var eventsCpu in FlaxEngine.ProfilingTools.EventsCPU)
{
sb.Append("\nName: " + eventsCpu.Name + " ");
foreach (var eventt in eventsCpu.Events)
{
#if FLAX_EDITOR
string eventName = eventt.Name;
#else
string eventName;
unsafe
{
var ptr1 = &eventt;
char* ptr2 = (char*)(new IntPtr((byte*)ptr1 + nameOffset.ToInt64()));
//fixed (char* name = &eventt)
{
eventName = new string(ptr2);
}
}
#endif
sb.Append(eventName + " " + (eventt.End-eventt.Start) + "ms, ");
}
}
#endif
((Label) control.Control).Text = sb.ToString();
/*if (!Platform.HasFocus)