Added parsing benchmark.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Parsers;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Avalonia.Benchmarks.Markup
|
||||
{
|
||||
[MemoryDiagnoser]
|
||||
public class Parsing
|
||||
{
|
||||
[Benchmark]
|
||||
public void ParseComplexSelector()
|
||||
{
|
||||
var selectorString = "ListBox > TextBox /template/ TextBlock[IsFocused=True]";
|
||||
var parser = new SelectorParser((ns, s) =>
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case "ListBox":
|
||||
return typeof(ListBox);
|
||||
case "TextBox":
|
||||
return typeof(TextBox);
|
||||
case "TextBlock":
|
||||
return typeof(TextBlock);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
var selector = parser.Parse(selectorString);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user