Skip to content

Enum.ToString method is resulting in slow performance. Fix it.#11229

Merged
SimaTian merged 5 commits intomainfrom
replace-enum-to-string
Jan 8, 2025
Merged

Enum.ToString method is resulting in slow performance. Fix it.#11229
SimaTian merged 5 commits intomainfrom
replace-enum-to-string

Conversation

@SimaTian
Copy link
Copy Markdown
Member

@SimaTian SimaTian commented Jan 6, 2025

Context

We recently merged #11202
While profiling, the VS profiler started complaining about the Enum.ToString() with a perf cost 0.14%
EnumToString
See also here:
https://learn.microsoft.com/en-us/visualstudio/profiling/performance-insights-enum-tostring?view=vs-2022

Changes Made

Introduced a function to do the conversion in a Reflection-less way.

@SimaTian SimaTian force-pushed the replace-enum-to-string branch from 3117080 to 878a618 Compare January 6, 2025 15:29
Comment thread src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs
Comment thread src/Build/BackEnd/Shared/TargetResult.cs Outdated
Comment thread src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs
Copy link
Copy Markdown
Member

@surayya-MS surayya-MS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment thread src/Build/BackEnd/Shared/TargetResult.cs Outdated
@SimaTian SimaTian merged commit 6ea6901 into main Jan 8, 2025
@SimaTian SimaTian deleted the replace-enum-to-string branch January 8, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants