wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Improve font performance in FamilyCollection.GetFontFromFamily

Open ThomasGoulet73 opened this issue 4 months ago • 0 comments

Description

I improved performance and allocations by using the new GetAlternateLookup introduced in .Net 9.0. This is a followup to dotnet/wpf#7794 where GetAlternateLookup wasn't available at the time.

Here's the result of my benchmark:

|          Method |     Mean |   Error |  StdDev | Ratio | RatioSD |   Gen0 | Allocated | Alloc Ratio |
|---------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:|
| LookupFamilyOld | 344.6 ns | 4.59 ns | 4.29 ns |  1.00 |    0.00 | 0.0706 |   1.16 KB |        1.00 |
| LookupFamilyNew | 333.0 ns | 3.23 ns | 2.86 ns |  0.97 |    0.02 | 0.0687 |   1.13 KB |        0.97 |

Customer Impact

Better perf.

Regression

No.

Testing

I ran FamilyCollection.GetFontFromFamily with different combinations to make sure that the result was the same.

Risk

Low.

Microsoft Reviewers: Open in CodeFlow

ThomasGoulet73 avatar Oct 03 '24 04:10 ThomasGoulet73