Skip to content

Conversation

@h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Jan 4, 2025

Currently blocked by #9364, hence draft.

Description

Optimizes parsing of colors and brushes from string and also conversion of colors to string.
It currently cherry-picks the ref-struct tokenizer from #9364, but it is directly dependent due to several changes over those previously done.

ParseContextColor (normal)

Method Mean [ns] Error [ns] StdDev [ns] Code Size [B] Gen0 Allocated [B]
Original 528.9 ns 10.28 ns 13.01 ns 3,138 B 0.0763 1288 B
PR__EDIT 331.3 ns 2.51 ns 2.22 ns 1,517 B 0.0114 192 B

ParseContextColor (edge case)

Method Mean [ns] Error [ns] StdDev [ns] Code Size [B] Gen0 Allocated [B]
Original 687.2 ns 6.62 ns 5.87 ns 2,971 B 0.1040 1752 B
PR__EDIT 384.9 ns 0.90 ns 0.84 ns 1,517 B 0.0114 192 B

ToString with Round-trip format

Method Mean [ns] Error [ns] StdDev [ns] Gen0 Code Size [B] Allocated [B]
Original 425.0 ns 1.64 ns 1.37 ns 0.0181 3,864 B 304 B
PR__EDIT 321.7 ns 0.89 ns 0.79 ns 0.0048 833 B 80 B

ToString with ColorContext

Method Mean [ns] Error [ns] StdDev [ns] Gen0 Code Size [B] Allocated [B]
Original 601.2 ns 4.31 ns 3.60 ns 0.0668 4,029 B 1120 B
PR__EDIT 419.1 ns 1.29 ns 1.15 ns 0.0138 1,506 B 232 B

Source data

// Benchmark 1
"ContextColor file://C:/Windows/system32/spool/drivers/color/RSWOP.icm 1.0, 0.0, 0.5, 1.0, 1.0"
// Benchmark 2
"ContextColor file://C:/Windows/system32/spool/drivers/color/RSWOP.icm 1.0,            1.0, 0.5,       0.0,       1.0"
// Benchmark 3+4
private static MILColorF scRgbColor = new() { a = 0.7667f, b = 0.2254f, g = 1.0f, r = 0.8458488f };
// Benchmark 4
uriString = "file://C:/Windows/system32/spool/drivers/color/RSWOP.icm",

Customer Impact

Improved performance, decreased allocations.

Regression

No.

Testing

Local build, assert tests.

Risk

Low to medium; will follow-up with unit tests once we're in that timeframe and past WPF tests.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners January 4, 2025 20:32
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jan 4, 2025
@h3xds1nz h3xds1nz marked this pull request as draft January 4, 2025 20:33
@h3xds1nz h3xds1nz force-pushed the color-parsers-speedup branch from bed76c6 to b2274ee Compare January 24, 2025 15:26
@h3xds1nz h3xds1nz force-pushed the color-parsers-speedup branch from d4250cf to e2e66c8 Compare March 24, 2025 18:04
@h3xds1nz
Copy link
Member Author

Resolved merge conflicts, validated with #10633 and #10632 tests.

@h3xds1nz h3xds1nz marked this pull request as ready for review March 24, 2025 18:05
@codecov
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 68.98551% with 107 lines in your changes missing coverage. Please review.

Project coverage is 11.19259%. Comparing base (3cc9d57) to head (75a04d6).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10225         +/-   ##
===================================================
+ Coverage   11.17950%   11.19259%   +0.01308%     
===================================================
  Files           3314        3315          +1     
  Lines         665182      665226         +44     
  Branches       74668       74684         +16     
===================================================
+ Hits           74364       74456         +92     
+ Misses        589525      589474         -51     
- Partials        1293        1296          +3     
Flag Coverage Δ
Debug 11.19259% <68.98551%> (+0.01308%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@h3xds1nz h3xds1nz force-pushed the color-parsers-speedup branch from e2e66c8 to da87fd5 Compare April 5, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant