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.
42 lines
1.1 KiB
42 lines
1.1 KiB
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using Avalonia.Controls;
|
|
using Avalonia.UnitTests;
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
namespace Avalonia.Benchmarks.Layout
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class Measure
|
|
{
|
|
private readonly TestRoot _root;
|
|
private readonly List<Control> _controls = new List<Control>();
|
|
|
|
public Measure()
|
|
{
|
|
var panel = new StackPanel();
|
|
|
|
_root = new TestRoot
|
|
{
|
|
Child = panel,
|
|
Renderer = new NullRenderer()
|
|
};
|
|
|
|
_controls.Add(panel);
|
|
_controls = ControlHierarchyCreator.CreateChildren(_controls, panel, 3, 5, 5);
|
|
|
|
_root.LayoutManager.ExecuteInitialLayoutPass();
|
|
}
|
|
|
|
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)]
|
|
public void Remeasure()
|
|
{
|
|
foreach (var control in _controls)
|
|
{
|
|
control.InvalidateMeasure();
|
|
}
|
|
|
|
_root.LayoutManager.ExecuteLayoutPass();
|
|
}
|
|
}
|
|
}
|
|
|