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

perf: add TrimStart(this StringBuilder #1548

Merged
merged 1 commit into from
Mar 21, 2025
Merged

Conversation

TimothyMakkison
Copy link
Contributor

@TimothyMakkison TimothyMakkison commented Mar 21, 2025

Prevents duplication of the result string, saving memory in certain cases, ie. a preprocessor directive at the start of a file.

Benchmarks (timing is inaccurate didn't bother rerunning it)

Before

Method Mean Error StdDev Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 98.32 ms 1.954 ms 2.327 ms 2000.0000 1000.0000 31.07 MB
Default_CodeFormatter_Complex 206.40 ms 3.671 ms 5.716 ms 5000.0000 2000.0000 54.58 MB

After

Method Mean Error StdDev Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 86.67 ms 1.675 ms 1.929 ms 2000.0000 1000.0000 31.07 MB
Default_CodeFormatter_Complex 182.89 ms 3.469 ms 6.766 ms 5000.0000 2000.0000 52.47 MB

Copy link
Owner

@belav belav left a comment

Choose a reason for hiding this comment

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

FYI I'm heading to the airport real soon so won't be around for the next 8 days. I may be able to get caught up before I take off.

Hoping to release all of these performance changes along with 1.0 in the next couple weeks, thanks again for all your hard work!

@belav belav merged commit e18fc06 into belav:main Mar 21, 2025
4 checks passed
@TimothyMakkison
Copy link
Contributor Author

FYI I'm heading to the airport real soon so won't be around for the next 8 days. I may be able to get caught up before I take off.

Happy journeys, hope you have a good holiday 😄

Hoping to release all of these performance changes along with 1.0 in the next couple weeks, thanks again for all your hard work!

Looking forward to it. I'm near the end of my changes. See #1551 for a general feel for the final result. I'll have to find a way to benchmark an actual run of multiple files, to see if I've overlooked something.

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.

2 participants