From 7e4ea18ca6d94ab91c5bcd908b7350bc610ea611 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 10 Dec 2015 15:56:25 -0800 Subject: [PATCH] Put statistic track class into agg. --- ApplicationView/MainApplicationWidget.cs | 55 +++++++----------------- MatterControlApplication.cs | 2 +- Submodules/agg-sharp | 2 +- 3 files changed, 17 insertions(+), 42 deletions(-) diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index 37f113ab5..a0f750095 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014, Lars Brubaker +Copyright (c) 2015, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -41,44 +41,6 @@ using System.Threading.Tasks; namespace MatterHackers.MatterControl { - public class StatisticsTracker - { - double valueTotal = 0; - long sampleCount = 0; - double currentMean = 0.0; - double currentDifferencSquared = 0.0; - - public double Mean { get { return valueTotal / sampleCount; } } - public double StandardDeviation - { - get - { - if (sampleCount > 2) - { - return Math.Sqrt(currentDifferencSquared / (sampleCount - 1)); - } - - return 0; - } - } - - public void AddValue(double value) - { - valueTotal += value; - double startingMean = currentMean; - if (sampleCount > 0) - { - currentMean += (value - startingMean) / sampleCount; - } - else - { - currentMean = value; - } - currentDifferencSquared += (value - startingMean) * (value - currentMean); - sampleCount++; - } - } - public abstract class ApplicationView : GuiWidget { public TopContainerWidget TopContainer; @@ -106,11 +68,14 @@ namespace MatterHackers.MatterControl private bool topIsHidden = false; #region automation test -#if false +#if true + StatisticsTracker testTracker = new StatisticsTracker(); bool item = true; bool firstDraw = true; AutomationRunner clickPreview; Stopwatch timeSinceLastClick = Stopwatch.StartNew(); + Stopwatch totalDrawTime = Stopwatch.StartNew(); + int drawCount = 0; public override void OnDraw(Graphics2D graphics2D) { if (firstDraw) @@ -138,7 +103,17 @@ namespace MatterHackers.MatterControl firstDraw = false; } + totalDrawTime.Restart(); base.OnDraw(graphics2D); + totalDrawTime.Stop(); + if (drawCount++ > 30 && testTracker.Count < 100) + { + testTracker.AddValue(totalDrawTime.ElapsedMilliseconds); + if (testTracker.Count == 100) + { + // TODO: report + } + } } #endif #endregion diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index c9ab91e57..368994f03 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -605,7 +605,7 @@ namespace MatterHackers.MatterControl } } - public override void OnDraw(Graphics2D graphics2D) + public override void OnDraw(Graphics2D graphics2D) { totalDrawTime.Restart(); GuiWidget.DrawCount = 0; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 21f2d8d24..2d45f6304 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 21f2d8d240a07f87aa30fe8f9bb10c001d5e8170 +Subproject commit 2d45f6304bd8bc3086eea6a576a65c513f831b14