Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SpriteFont.Measure take zero allocations #19300

Merged
merged 1 commit into from
Apr 3, 2021

Conversation

teinarss
Copy link
Contributor

By using spans instead of splitting strings we avoids making allocations, which will help performance.

@teinarss
Copy link
Contributor Author

Benchmark


|                 Method |       Mean |    Error |   StdDev |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------------- |-----------:|---------:|---------:|-------:|------:|------:|----------:|
|   Messure_New_one_line |   125.7 ns |  2.55 ns |  2.51 ns |      - |     - |     - |         - |
|   Messure_old_one_line |   295.0 ns |  0.66 ns |  0.59 ns | 0.0153 |     - |     - |      64 B |
| Messure_New_multi_line |   907.6 ns | 13.16 ns | 12.31 ns |      - |     - |     - |         - |
| Messure_old_multi_line | 2,163.1 ns | 30.47 ns | 27.01 ns | 0.1144 |     - |     - |     480 B |

@reaperrr reaperrr merged commit 3d381e6 into OpenRA:bleed Apr 3, 2021
@teinarss teinarss deleted the zero_font_messure branch April 15, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants