Skip to content

Replace String.Format with StringBuilder for Estimated FPS#925

Merged
aHooder merged 4 commits into117HD:masterfrom
RuffledPlume:EstimatedFPSFormatting
Feb 26, 2026
Merged

Replace String.Format with StringBuilder for Estimated FPS#925
aHooder merged 4 commits into117HD:masterfrom
RuffledPlume:EstimatedFPSFormatting

Conversation

@RuffledPlume
Copy link
Copy Markdown
Contributor

Replaced String.Format with StringBuilder for Estimated FPS, which significantly reduces garbage generated with the frameTimer open.

Added Round(v, n) to be able to round to a set amount of decimal places
Along with the different permutations of the function

Master:
image

PR:
image

@aHooder
Copy link
Copy Markdown
Member

aHooder commented Feb 26, 2026

Can you check this out with IntelliJ's profiler again? 🙂

I figured since String.format is convenient enough that two more uses of it have apparently popped up since this PR was written, we might as well just implement a wrapper for it which doesn't allocate quite as much.

Regarding the extra math functions, I'm not too sure if they'll actually be useful, but I suppose we just want any general math function in there, so it's probably fine. Not too hard to review at least 🙂

RuffledPlume and others added 4 commits February 26, 2026 19:13
Added Round(v, n) to be able to round to a set amount of decimal places
Since this is just gonna keep coming back to bite us, this is a decent
compromise I think. We don't *really* need the speed, mostly just
allocation reduction is nice.
@RuffledPlume RuffledPlume force-pushed the EstimatedFPSFormatting branch from 6475ff6 to 8f4c9ac Compare February 26, 2026 19:13
@RuffledPlume
Copy link
Copy Markdown
Contributor Author

image Its no longer a hotspot of memory allocations, compared to the rest of the frame

@aHooder aHooder merged commit 69a7945 into 117HD:master Feb 26, 2026
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