Reduced the drawing in part thumbnail widget a bit

Made the draw ms be averaged over 64 draws so it is easier to see.
This commit is contained in:
larsbrubaker 2014-12-28 08:26:29 -08:00
parent a68276154b
commit 54422e50bc
2 changed files with 19 additions and 8 deletions

View file

@ -280,6 +280,11 @@ namespace MatterHackers.MatterControl
Stopwatch totalDrawTime = new Stopwatch();
int drawCount = 0;
static readonly int averageCount = 64;
int averageIndex = 0;
int[] averageMsArray = new int[averageCount];
int totalMsInArray = 0;
Gaming.Game.DataViewGraph msGraph = new Gaming.Game.DataViewGraph(new Vector2(20, 500), 50, 50, 0, 200);
public override void OnDraw(Graphics2D graphics2D)
{
@ -287,11 +292,15 @@ namespace MatterHackers.MatterControl
GuiWidget.DrawCount = 0;
base.OnDraw(graphics2D);
totalDrawTime.Stop();
totalMsInArray -= averageMsArray[averageIndex % averageCount];
averageMsArray[averageIndex % averageCount] = (int)totalDrawTime.ElapsedMilliseconds;
totalMsInArray += averageMsArray[averageIndex % averageCount];
averageIndex++;
if (ShowMemoryUsed)
{
long memory = GC.GetTotalMemory(false);
this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, drawCount = {7}".FormatWith(memory, totalDrawTime.ElapsedMilliseconds, drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount);
this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, drawCount = {7}".FormatWith(memory, totalMsInArray/averageCount, drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount);
if (DoCGCollectEveryDraw)
{
GC.Collect();