dotnet / dotnet/wpf

Startup cost of XamlServices parsing is 27% slower on .NETCore than on .NET Framework

Open
#94 44 comments 22 reactions 0 assignees View on GitHub
Bug Performance rank20 regression
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .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` 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:
```cs
public class BenchmarkTests
{
static readonly string xamlString = @"";

[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:
``` ini

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 |

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.