From e3c70b0268591d268d82de91883737513631d668 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Sun, 2 Mar 2014 15:28:47 -0800 Subject: [PATCH] Removed all the internal performance monitoring in favor of an external tool. --- ControlElements/TextImageButtonFactory.cs | 34 +++++++++++++++++++--- MatterControlApplication.cs | 33 +++------------------ PartPreviewWindow/PartPreviewMainWindow.cs | 28 ------------------ PartPreviewWindow/View3DTransfromPart.cs | 3 -- 4 files changed, 34 insertions(+), 64 deletions(-) diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index 5a38b07b1..6a564d7bc 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -1,4 +1,33 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -79,10 +108,8 @@ namespace MatterHackers.MatterControl VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren; } - static NamedExecutionTimer drawTimer = new NamedExecutionTimer("TextImgBtnFctry"); public override void OnDraw(Graphics2D graphics2D) { - drawTimer.Start(); if (borderColor.Alpha0To255 > 0) { RectangleDouble boarderRectangle = LocalBounds; @@ -102,7 +129,6 @@ namespace MatterHackers.MatterControl } base.OnDraw(graphics2D); - drawTimer.Stop(); } } diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 1cfe0f9c8..20ec90929 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -69,7 +69,6 @@ namespace MatterHackers.MatterControl bool firstDraw = true; bool ShowMemoryUsed = false; bool DoCGCollectEveryDraw = false; - bool ShowDrawTimingWindow = false; public MatterControlApplication(double width, double height) : base(width, height) @@ -99,15 +98,13 @@ namespace MatterHackers.MatterControl ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; - - case "SHOW_DRAW_TIMING": - ShowDrawTimingWindow = true; - break; } } //WriteTestGCodeFile(); +#if !DEBUG if (File.Exists("RunUnitTests.txt")) +#endif { GuiHalWidget.SetClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); @@ -274,24 +271,15 @@ namespace MatterHackers.MatterControl Stopwatch totalDrawTime = new Stopwatch(); int drawCount = 0; - PerformanceFeedbackWindow timingWindow = null; - static NamedExecutionTimer drawTimer = new NamedExecutionTimer("MatterContorl Draw"); public override void OnDraw(Graphics2D graphics2D) { - if (ShowDrawTimingWindow) - { - ExecutionTimer.Instance.Reset(); - totalDrawTime.Restart(); - } - - drawTimer.Start(); + totalDrawTime.Restart(); base.OnDraw(graphics2D); - drawTimer.Stop(); + totalDrawTime.Stop(); if (ShowMemoryUsed) { - totalDrawTime.Stop(); long memory = GC.GetTotalMemory(false); this.Title = string.Format("Allocated = {0:n0} : {1}ms, d{2} Size = {3}x{4}", memory, totalDrawTime.ElapsedMilliseconds, drawCount++, this.Width, this.Height); if (DoCGCollectEveryDraw) @@ -300,19 +288,6 @@ namespace MatterHackers.MatterControl } } - if (ShowDrawTimingWindow) - { - if (timingWindow == null) - { - timingWindow = new PerformanceFeedbackWindow(); - } - - if (totalDrawTime.Elapsed.TotalSeconds > .05) - { - timingWindow.ShowResults(totalDrawTime.Elapsed.TotalSeconds); - } - } - if (firstDraw) { Parent.MinimumSize = new Vector2(590, 540); diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index f77e65ca6..8a5da6af6 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -99,34 +99,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - PerformanceFeedbackWindow timingWindow = null; - Stopwatch totalDrawTime = new Stopwatch(); - static NamedExecutionTimer partPreviewDraw = new NamedExecutionTimer("PartPreview Draw"); - public override void OnDraw(Graphics2D graphics2D) - { - ExecutionTimer.Instance.Reset(); - - totalDrawTime.Restart(); - partPreviewDraw.Start(); - base.OnDraw(graphics2D); - partPreviewDraw.Stop(); - totalDrawTime.Stop(); -#if true //DEBUG -#if false - if (timingWindow == null) - { - string staticDataPath = ApplicationDataStorage.Instance.ApplicationStaticDataPath; - string fontPath = Path.Combine(staticDataPath, "Fonts", "LiberationMono.svg"); - TypeFace boldTypeFace = TypeFace.LoadSVG(fontPath); - timingWindow = new PerformanceFeedbackWindow(new StyledTypeFace(boldTypeFace, 12)); - //} - //{ - timingWindow.ShowResults(totalDrawTime.Elapsed.TotalSeconds); - } -#endif -#endif - } - event EventHandler unregisterEvents; private void AddHandlers() { diff --git a/PartPreviewWindow/View3DTransfromPart.cs b/PartPreviewWindow/View3DTransfromPart.cs index 8788f00cc..06b60f0ba 100644 --- a/PartPreviewWindow/View3DTransfromPart.cs +++ b/PartPreviewWindow/View3DTransfromPart.cs @@ -221,12 +221,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - static NamedExecutionTimer drawTimer = new NamedExecutionTimer("View3DTrans"); public override void OnDraw(Graphics2D graphics2D) { - drawTimer.Start(); base.OnDraw(graphics2D); - drawTimer.Stop(); } public override void OnMouseMove(MouseEventArgs mouseEvent)