<Compile Include="src\GraphicObjects\HueSelector.cs" />
<Compile Include="src\GraphicObjects\SaturationValueSelector.cs" />
<Compile Include="src\IML\EventBinding.cs" />
+ <Compile Include="src\PerformanceMeasure.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
//testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" };
//testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
- //testFiles = new string [] { @"Interfaces/TemplatedContainer/test_Listbox.crow" };
- //testFiles = new string [] { @"Interfaces/TemplatedControl/testItemTemplateTag.crow" };
- //testFiles = new string [] { @"Interfaces/Divers/test2WayBinding.crow" };
- //testFiles = new string [] { @"Interfaces/Divers/testPropLess.crow" };
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
GraphicObject w = CrowInterface.LoadInterface ("Interfaces/Divers/0.crow");
w.DataSource = this;
return;
+ }else if (e.Key == OpenTK.Input.Key.F7) {
+ GraphicObject w = CrowInterface.LoadInterface ("Interfaces/Divers/perfMeasures.crow");
+ w.DataSource = this;
+ return;
} else if (e.Key == OpenTK.Input.Key.F2)
idx--;
else if (e.Key == OpenTK.Input.Key.F3)
--- /dev/null
+<?xml version="1.0"?>
+<Window Focusable="true" Title="Measures" Width="30%" Height="Fit" MinimumSize="100,100">
+ <ListBox Data="{PerfMeasures}"
+ ItemTemplate="#Tests.Interfaces.perfMsr.crow"/>
+</Window>
--- /dev/null
+<?xml version="1.0"?>
+<GroupBox CornerRadius="0" Margin="0" Caption="{Name}" Height="Fit" Width="160">
+ <VerticalStack>
+ <HorizontalStack>
+ <Label Text="Current:" Style="FpsLabel"/>
+ <Label Text="{current}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Minimum:" Style="FpsLabel"/>
+ <Label Text="{minimum}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Mean:" Style="FpsLabel"/>
+ <Label Text="{mean}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Maximum:" Style="FpsLabel"/>
+ <Label Text="{maximum}" Style="FpsDisp"/>
+ </HorizontalStack>
+<!-- <HorizontalStack>
+ <Label Text="Total:" Style="FpsLabel"/>
+ <Label Text="{total}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Cpt:" Style="FpsLabel"/>
+ <Label Text="{cptMeasures}" Style="FpsDisp"/>
+ </HorizontalStack>-->
+ <Button Caption="Reset" MouseClick="onResetClick"/>
+ </VerticalStack>
+</GroupBox>
using System.Threading;
using OpenTK;
using OpenTK.Graphics.OpenGL;
+using System.Collections.Generic;
namespace Crow
{
if (frameCpt % 3 == 0)
ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
#if MEASURE_TIME
- ValueChanged.Raise (this, new ValueChangeEventArgs ("update",
- this.CrowInterface.updateTime.ElapsedTicks.ToString () + " ticks"));
- ValueChanged.Raise (this, new ValueChangeEventArgs ("layouting",
- this.CrowInterface.layoutTime.ElapsedTicks.ToString () + " ticks"));
- ValueChanged.Raise (this, new ValueChangeEventArgs ("drawing",
- this.CrowInterface.drawingTime.ElapsedTicks.ToString () + " ticks"));
- ValueChanged.Raise (this, new ValueChangeEventArgs ("clipping",
- this.CrowInterface.clippingTime.ElapsedTicks.ToString () + " ticks"));
+ foreach (PerformanceMeasure m in PerfMeasures)
+ m.NotifyChanges();
#endif
}
}
{
CrowInterface = new Interface ();
+ #if MEASURE_TIME
+ PerfMeasures = new List<PerformanceMeasure> (
+ new PerformanceMeasure[] {
+ this.CrowInterface.updateMeasure,
+ this.CrowInterface.layoutingMeasure,
+ this.CrowInterface.clippingMeasure,
+ this.CrowInterface.drawingMeasure
+ }
+ );
+ #endif
+
Thread t = new Thread (interfaceThread);
t.IsBackground = true;
t.Start ();
#endregion
+ #if MEASURE_TIME
+ public List<PerformanceMeasure> PerfMeasures;
+ #endif
+
void interfaceThread()
{
CrowInterface.Quit += Quit;
<None Include="Interfaces\Unsorted\testFileDialog.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\Divers\perfMeasures.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
<EmbeddedResource Include="test.style" />
<EmbeddedResource Include="Interfaces\treeList.crow" />
<EmbeddedResource Include="Interfaces\CheckBox2.imlt" />
+ <EmbeddedResource Include="Interfaces\perfMsr.crow" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Crow.csproj">
#endregion
#if MEASURE_TIME
- public Stopwatch clippingTime = new Stopwatch ();
- public Stopwatch layoutTime = new Stopwatch ();
- public Stopwatch updateTime = new Stopwatch ();
- public Stopwatch drawingTime = new Stopwatch ();
+ public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 100);
+ public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 100);
+ public PerformanceMeasure updateMeasure = new PerformanceMeasure("Update", 100);
+ public PerformanceMeasure drawingMeasure = new PerformanceMeasure("Drawing", 100);
#endif
public List<GraphicObject> GraphicTree = new List<GraphicObject>();
return;
#if MEASURE_TIME
- updateTime.Restart();
+ updateMeasure.StartCycle();
#endif
processLayouting ();
processDrawing ();
#if MEASURE_TIME
- updateTime.Stop ();
+ updateMeasure.StopCycle();
#endif
Monitor.Exit (UpdateMutex);
}
void processLayouting(){
#if MEASURE_TIME
- layoutTime.Restart();
+ layoutingMeasure.StartCycle();
#endif
DiscardQueue = new Queue<LayoutingQueueItem> ();
lock (LayoutMutex) {
DiscardQueue = null;
#if MEASURE_TIME
- layoutTime.Stop ();
+ layoutingMeasure.StopCycle();
#endif
}
void clippingRegistration(){
#if MEASURE_TIME
- clippingTime.Restart ();
+ clippingMeasure.StartCycle();
#endif
GraphicObject g = null;
while (DrawingQueue.Count > 0) {
}
#if MEASURE_TIME
- clippingTime.Stop ();
+ clippingMeasure.StopCycle();
#endif
}
void processDrawing(){
#if MEASURE_TIME
- drawingTime.Restart();
+ drawingMeasure.StartCycle();
#endif
using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
using (ctx = new Context (surf)){
}
}
#if MEASURE_TIME
- drawingTime.Stop ();
+ drawingMeasure.StopCycle();
#endif
}
--- /dev/null
+//
+// PerformanceMeasure.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2017 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Diagnostics;
+
+namespace Crow
+{
+ public class PerformanceMeasure : IValueChange {
+ #region IValueChange implementation
+ public event EventHandler<ValueChangeEventArgs> ValueChanged;
+ public virtual void NotifyValueChanged(string MemberName, object _value)
+ {
+ if (ValueChanged != null)
+ ValueChanged.Invoke(this, new ValueChangeEventArgs(MemberName, _value));
+ }
+ #endregion
+
+ public Stopwatch timer = new Stopwatch ();
+ public string Name;
+ public long current, minimum, maximum, total, cptMeasures;
+ public long cancelLimit;
+
+ public PerformanceMeasure(string name = "unamed", long _cancelLimit = 0){
+ Name = name;
+ cancelLimit = _cancelLimit;
+ ResetStats ();
+ }
+
+ public void StartCycle(){
+ timer.Restart();
+ }
+ public void StopCycle(){
+ timer.Stop();
+ computeStats ();
+ }
+ public void NotifyChanges(){
+ if (cptMeasures == 0)
+ return;
+ NotifyValueChanged("minimum", minimum);
+ NotifyValueChanged("maximum", maximum);
+ NotifyValueChanged("current", current);
+ // NotifyValueChanged("total", total);
+ // NotifyValueChanged("cptMeasures", cptMeasures);
+ NotifyValueChanged("mean", total / cptMeasures);
+ }
+
+ void computeStats(){
+ current = timer.ElapsedTicks;
+ if (current < cancelLimit)
+ return;
+ cptMeasures++;
+ total += timer.ElapsedTicks;
+ if (timer.ElapsedTicks < minimum)
+ minimum = timer.ElapsedTicks;
+ if (timer.ElapsedTicks > maximum)
+ maximum = timer.ElapsedTicks;
+ }
+ void ResetStats(){
+ Debug.WriteLine("reset measure cpt:{0}",cptMeasures);
+ cptMeasures = total = current = maximum = 0;
+ minimum = long.MaxValue;
+ }
+ void onResetClick(object sender, MouseButtonEventArgs e){
+ ResetStats();
+ }
+ }
+}
+