Browse Source

Modified benchmark.

pull/472/head
Steven Kirk 11 years ago
parent
commit
14360b1b7b
  1. 35
      tests/Perspex.Benchmarks/Controls/Initialization.cs
  2. 2
      tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj
  3. 1
      tests/Perspex.Benchmarks/Program.cs
  4. 55
      tests/Perspex.Benchmarks/Styling/ApplyStyling.cs

35
tests/Perspex.Benchmarks/Controls/Initialization.cs

@ -1,35 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Perspex.Controls;
using Perspex.Layout;
using Perspex.UnitTests;
using Perspex.VisualTree;
namespace Perspex.Benchmarks.Controls
{
public class Initialization
{
[Benchmark]
public void Add_And_Style_TextBox()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var window = new Window
{
Content = new TextBox(),
};
LayoutManager.Instance.ExecuteInitialLayoutPass(window);
if (((TextBox)window.Content).GetVisualChildren().Count() != 1)
{
throw new Exception("Control not styled.");
}
}
}
}
}

2
tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj

@ -65,7 +65,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\Initialization.cs" />
<Compile Include="Styling\ApplyStyling.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

1
tests/Perspex.Benchmarks/Program.cs

@ -5,7 +5,6 @@ using System.Linq;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Perspex.Benchmarks.Controls;
namespace Perspex.Benchmarks
{

55
tests/Perspex.Benchmarks/Styling/ApplyStyling.cs

@ -0,0 +1,55 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Perspex.Controls;
using Perspex.UnitTests;
using Perspex.VisualTree;
namespace Perspex.Benchmarks.Styling
{
public class ApplyStyling : IDisposable
{
private IDisposable _app;
private Window _window;
public ApplyStyling()
{
_app = UnitTestApplication.Start(TestServices.StyledWindow);
TextBox textBox;
_window = new Window
{
Content = textBox = new TextBox(),
};
_window.ApplyTemplate();
textBox.ApplyTemplate();
var border = (Border)textBox.GetVisualChildren().Single();
if (border.BorderThickness != 2)
{
throw new Exception("Styles not applied.");
}
_window.Content = null;
}
public void Dispose()
{
_app.Dispose();
}
[Benchmark]
public void Add_And_Style_TextBox()
{
var textBox = new TextBox();
_window.Content = textBox;
textBox.ApplyTemplate();
}
}
}
Loading…
Cancel
Save