Adding in a new performance test structure.
This commit is contained in:
parent
e96a439e4a
commit
a07a15a7c7
3 changed files with 108 additions and 67 deletions
|
|
@ -67,56 +67,17 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private bool topIsHidden = false;
|
||||
|
||||
#region automation test
|
||||
#if true
|
||||
StatisticsTracker testTracker = new StatisticsTracker("ApplicationViewFrameRate");
|
||||
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)
|
||||
{
|
||||
clickPreview = new AutomationRunner();
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (clickPreview != null && timeSinceLastClick.Elapsed.TotalSeconds > 5)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
clickPreview.ClickByName("Library Tab");
|
||||
}
|
||||
else
|
||||
{
|
||||
clickPreview.ClickByName("Controls Tab");
|
||||
}
|
||||
item = !item;
|
||||
timeSinceLastClick.Restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
PerformanceTests.SwitchBetweenWidgets(this, "Library Tab", "Controls Tab", .1);
|
||||
firstDraw = false;
|
||||
}
|
||||
|
||||
totalDrawTime.Restart();
|
||||
base.OnDraw(graphics2D);
|
||||
totalDrawTime.Stop();
|
||||
if (drawCount++ > 30 && testTracker.Count < 100)
|
||||
{
|
||||
testTracker.AddValue(totalDrawTime.ElapsedMilliseconds);
|
||||
if (testTracker.Count == 100)
|
||||
{
|
||||
Trace.WriteLine("StatisticsTrackerReport: " + Newtonsoft.Json.JsonConvert.SerializeObject(testTracker));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public override void HideTopContainer()
|
||||
{
|
||||
|
|
@ -238,43 +199,17 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
}
|
||||
|
||||
#region automation test
|
||||
#if false
|
||||
bool item = true;
|
||||
bool firstDraw = true;
|
||||
AutomationRunner clickPreview;
|
||||
Stopwatch timeSinceLastClick = Stopwatch.StartNew();
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
if (firstDraw)
|
||||
{
|
||||
clickPreview = new AutomationRunner();
|
||||
Task.Run(() =>
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
if (clickPreview != null && timeSinceLastClick.Elapsed.TotalSeconds > 5)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
clickPreview.ClickByName("Library Tab");
|
||||
}
|
||||
else
|
||||
{
|
||||
clickPreview.ClickByName("History Tab");
|
||||
}
|
||||
item = !item;
|
||||
timeSinceLastClick.Restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
PerformanceTests.SwitchBetweenWidgets(this, "Library Tab", "History Tab", .1);
|
||||
firstDraw = false;
|
||||
}
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
public override void AddElements()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@
|
|||
<Compile Include="PartPreviewWindow\ViewGcodeBasic.cs" />
|
||||
<Compile Include="PartPreviewWindow\PartPreviewMainWindow.cs" />
|
||||
<Compile Include="Queue\OptionsMenu\PartsSheetCreator.cs" />
|
||||
<Compile Include="Utilities\PerformanceTests.cs" />
|
||||
<Compile Include="Utilities\WebUtilities\JsonResponseDictionary.cs" />
|
||||
<Compile Include="PrinterCommunication\PrinterConnectionAndCommunication.cs" />
|
||||
<Compile Include="PrinterControls\PrintLevelingPlane.cs" />
|
||||
|
|
|
|||
105
Utilities/PerformanceTests.cs
Normal file
105
Utilities/PerformanceTests.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public static class PerformanceTests
|
||||
{
|
||||
public static void SwitchBetweenWidgets(GuiWidget systemWindow, string firstWidgetName, string secondWidgetName, double switchTimeSeconds)
|
||||
{
|
||||
StatisticsTracker testTracker = new StatisticsTracker("SwitchBetweenTabs");
|
||||
bool item = true;
|
||||
bool done = false;
|
||||
bool firstDraw = true;
|
||||
AutomationRunner clickPreview;
|
||||
Stopwatch timeSinceLastClick = Stopwatch.StartNew();
|
||||
Stopwatch totalDrawTime = Stopwatch.StartNew();
|
||||
int drawCount = 0;
|
||||
|
||||
DrawEventHandler beforeDraw = (sender, e) =>
|
||||
{
|
||||
if (firstDraw)
|
||||
{
|
||||
clickPreview = new AutomationRunner();
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (!done)
|
||||
{
|
||||
if (clickPreview != null && timeSinceLastClick.Elapsed.TotalSeconds > switchTimeSeconds)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
clickPreview.ClickByName(firstWidgetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
clickPreview.ClickByName(secondWidgetName);
|
||||
}
|
||||
item = !item;
|
||||
timeSinceLastClick.Restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
firstDraw = false;
|
||||
}
|
||||
|
||||
totalDrawTime.Restart();
|
||||
};
|
||||
|
||||
systemWindow.DrawBefore += beforeDraw;
|
||||
|
||||
DrawEventHandler afterDraw = null;
|
||||
afterDraw = (sender, e) =>
|
||||
{
|
||||
totalDrawTime.Stop();
|
||||
if (drawCount++ > 30 && testTracker.Count < 100)
|
||||
{
|
||||
testTracker.AddValue(totalDrawTime.ElapsedMilliseconds);
|
||||
if (testTracker.Count == 100)
|
||||
{
|
||||
Trace.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(testTracker));
|
||||
systemWindow.DrawBefore -= beforeDraw;
|
||||
systemWindow.DrawBefore -= afterDraw;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
systemWindow.DrawAfter += afterDraw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue