csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Styling;
|
|
using Avalonia.UnitTests;
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
namespace Avalonia.Benchmarks.Styling
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class StyleAttachBenchmark : IDisposable
|
|
{
|
|
private readonly IDisposable _app;
|
|
private readonly TestRoot _root;
|
|
private readonly TextBox _control;
|
|
|
|
public StyleAttachBenchmark()
|
|
{
|
|
_app = UnitTestApplication.Start(
|
|
TestServices.StyledWindow.With(
|
|
renderInterface: new NullRenderingPlatform(),
|
|
threadingInterface: new NullThreadingPlatform()));
|
|
|
|
_root = new TestRoot(true, null)
|
|
{
|
|
Renderer = new NullRenderer(),
|
|
};
|
|
|
|
_control = new TextBox();
|
|
}
|
|
|
|
[Benchmark]
|
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
|
public void AttachTextBoxStyles()
|
|
{
|
|
var styles = UnitTestApplication.Current.Styles;
|
|
|
|
styles.TryAttach(_control, UnitTestApplication.Current);
|
|
((IStyleable)_control).DetachStyles();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_app.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|