- .NET Core Version: 3.0 Preview1
- Windows version: 1803
- Does the bug reproduce also in WPF for .NET Framework 4.8?: No
Problem description:
I expected/hoped that with the XmlReader hopefully being Span<T> based. the XAML parser would be faster in .NET Core than the .NET Framework equivalent. However that's not what I'm seeing with this benchmark:
public class BenchmarkTests
{
static readonly string xamlString = @"<MyObject xmlns=""clr-namespace:XamlBenchmark;assembly=XamlBenchmark"" StringProperty=""Hello World"" Int32Property=""1234"" DoubleProperty=""123.4567890"" FloatProperty=""-0.9876"" />";
[Benchmark]
public object Test1()
{
object instance = System.Xaml.XamlServices.Parse(xamlString);
return instance;
}
}
public class MyObject
{
public string StringProperty { get; set; }
public int Int32Property { get; set; }
public double DoubleProperty { get; set; }
public float FloatProperty { get; set; }
}
Here are the results:
BenchmarkDotNet=v0.11.3, OS=Windows 10.0.17763.1 (1809/October2018Update/Redstone5)
Intel Xeon CPU E5-1620 v3 3.50GHz, 1 CPU, 8 logical and 4 physical cores
[Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3190.0
Job-FQKGZY : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3190.0
Job-YTBJBT : .NET Core 3.0.0-preview-27122-01 (CoreCLR 4.6.27121.03, CoreFX 4.7.18.57103), 64bit RyuJIT
| Method |
Runtime |
Toolchain |
Mean |
Error |
StdDev |
Ratio |
RatioSD |
| Test1 |
Clr |
net472 |
363.3 us |
7.139 us |
7.639 us |
1.00 |
0.00 |
| Test1 |
Core |
netcoreapp3.0 |
461.6 us |
9.078 us |
8.048 us |
1.27 |
0.03 |
Problem description:
I expected/hoped that with the XmlReader hopefully being
Span<T>based. the XAML parser would be faster in .NET Core than the .NET Framework equivalent. However that's not what I'm seeing with this benchmark:Here are the results: