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

Improve LookupContentTypeForImageUri performance in XpsFixedPageReaderWriter.cs #5393

Merged

Conversation

lindexi
Copy link
Member

@lindexi lindexi commented Sep 26, 2021

Description

I wrote the test demo code and I found an improvement in performance.

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
LookupContentTypeForImageUri 114.17 ns 3.096 ns 9.130 ns 0.0153 - - 64 B
LookupContentTypeForImageUriIgnoreCase 40.84 ns 0.975 ns 2.874 ns - - - -
LookupContentTypeForImageUri 115.00 ns 3.858 ns 11.375 ns 0.0153 - - 64 B
LookupContentTypeForImageUriIgnoreCase 55.19 ns 1.913 ns 5.642 ns - - - -
LookupContentTypeForImageUri 84.97 ns 1.773 ns 3.198 ns 0.0153 - - 64 B
LookupContentTypeForImageUriIgnoreCase 40.82 ns 0.869 ns 1.099 ns - - - -
LookupContentTypeForImageUri 91.29 ns 1.693 ns 1.322 ns 0.0153 - - 64 B
LookupContentTypeForImageUriIgnoreCase 47.45 ns 0.961 ns 0.852 ns - - - -
LookupContentTypeForImageUri 103.35 ns 1.876 ns 2.234 ns 0.0153 - - 64 B
LookupContentTypeForImageUriIgnoreCase 58.83 ns 1.231 ns 1.643 ns - - - -
LookupContentTypeForImageUri 52.88 ns 0.973 ns 0.911 ns 0.0076 - - 32 B
LookupContentTypeForImageUriIgnoreCase 31.78 ns 0.701 ns 1.264 ns - - - -
LookupContentTypeForImageUri 65.51 ns 1.325 ns 1.361 ns 0.0076 - - 32 B
LookupContentTypeForImageUriIgnoreCase 44.33 ns 0.949 ns 0.841 ns - - - -
LookupContentTypeForImageUri 66.49 ns 1.383 ns 2.386 ns 0.0076 - - 32 B
LookupContentTypeForImageUriIgnoreCase 40.33 ns 0.688 ns 0.643 ns - - - -
LookupContentTypeForImageUri 76.48 ns 1.560 ns 1.669 ns 0.0076 - - 32 B
LookupContentTypeForImageUriIgnoreCase 47.74 ns 1.015 ns 1.640 ns - - - -
LookupContentTypeForImageUri 83.05 ns 1.536 ns 1.769 ns 0.0076 - - 32 B
LookupContentTypeForImageUriIgnoreCase 58.10 ns 1.177 ns 1.156 ns - - - -

Benchmark: https://github.com/lindexi/lindexi_gd/tree/983c668ea7cd308a510c043b5d2e5de74da8efe7/ColalejayJearbearlerlekere

See #4766

Customer Impact

None

Regression

Testing

Just CI and my demo code.

Risk

Low. I did not change the behavior of the code.

…rWriter.cs

I wrote the test demo code and I found an improvement in performance.

|                                 Method |      Mean |    Error |    StdDev |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|--------------------------------------- |----------:|---------:|----------:|-------:|------:|------:|----------:|
|           LookupContentTypeForImageUri | 114.17 ns | 3.096 ns |  9.130 ns | 0.0153 |     - |     - |      64 B |
| LookupContentTypeForImageUriIgnoreCase |  40.84 ns | 0.975 ns |  2.874 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri | 115.00 ns | 3.858 ns | 11.375 ns | 0.0153 |     - |     - |      64 B |
| LookupContentTypeForImageUriIgnoreCase |  55.19 ns | 1.913 ns |  5.642 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  84.97 ns | 1.773 ns |  3.198 ns | 0.0153 |     - |     - |      64 B |
| LookupContentTypeForImageUriIgnoreCase |  40.82 ns | 0.869 ns |  1.099 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  91.29 ns | 1.693 ns |  1.322 ns | 0.0153 |     - |     - |      64 B |
| LookupContentTypeForImageUriIgnoreCase |  47.45 ns | 0.961 ns |  0.852 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri | 103.35 ns | 1.876 ns |  2.234 ns | 0.0153 |     - |     - |      64 B |
| LookupContentTypeForImageUriIgnoreCase |  58.83 ns | 1.231 ns |  1.643 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  52.88 ns | 0.973 ns |  0.911 ns | 0.0076 |     - |     - |      32 B |
| LookupContentTypeForImageUriIgnoreCase |  31.78 ns | 0.701 ns |  1.264 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  65.51 ns | 1.325 ns |  1.361 ns | 0.0076 |     - |     - |      32 B |
| LookupContentTypeForImageUriIgnoreCase |  44.33 ns | 0.949 ns |  0.841 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  66.49 ns | 1.383 ns |  2.386 ns | 0.0076 |     - |     - |      32 B |
| LookupContentTypeForImageUriIgnoreCase |  40.33 ns | 0.688 ns |  0.643 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  76.48 ns | 1.560 ns |  1.669 ns | 0.0076 |     - |     - |      32 B |
| LookupContentTypeForImageUriIgnoreCase |  47.74 ns | 1.015 ns |  1.640 ns |      - |     - |     - |         - |
|           LookupContentTypeForImageUri |  83.05 ns | 1.536 ns |  1.769 ns | 0.0076 |     - |     - |      32 B |
| LookupContentTypeForImageUriIgnoreCase |  58.10 ns | 1.177 ns |  1.156 ns |      - |     - |     - |         - |

Benchmark: https://github.com/lindexi/lindexi_gd/tree/983c668ea7cd308a510c043b5d2e5de74da8efe7/ColalejayJearbearlerlekere
@lindexi lindexi requested a review from a team as a code owner September 26, 2021 13:06
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Sep 26, 2021
@ghost ghost requested review from fabiant3, ryalanms and SamBent September 26, 2021 13:06
@pchaurasia14 pchaurasia14 added the Community Contribution A label for all community Contributions label Jul 20, 2022
@ghost ghost assigned lindexi Jul 20, 2022
@dipeshmsft dipeshmsft self-assigned this Jan 18, 2023
@dipeshmsft
Copy link
Member

Thank you @lindexi for your contribution.

@lindexi
Copy link
Member Author

lindexi commented Feb 1, 2023

Thank you @dipeshmsft

@ghost ghost locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

3 participants