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

DrawRect is Extremely CPU intensive #31

Open
EmperiorEric opened this issue Sep 1, 2015 · 1 comment
Open

DrawRect is Extremely CPU intensive #31

EmperiorEric opened this issue Sep 1, 2015 · 1 comment

Comments

@EmperiorEric
Copy link
Contributor

I used this label in a game that was running 60fps. My entire game update loop ran about 40% of the CPU at the my intense parts. THLabel ran at 14%. Those percentages are over a minute of gameplay with the THLabel changing its text once a second.

I had to work around it with snapshots of THLabels for various words generated before the game starts.

However, looking at the DrawRect briefly I see some places for speed improvements. It will likely never be fast enough for 60fps rendering as I know Core Text can be extremely expensive. But every little bit of CPU we can save means better battery life under normal operating conditions.

As people fill this thread with ideas, I'll see if I can find time to implement a few.

@tobihagemann
Copy link
Owner

Thanks for your feedback! So far I just have guessed that performance could be an issue, but I have never done any benchmarks.

Let's say we call drawRect: 60 times a second, and 59 times it's just drawing the same text over and over again. We could save some computation there! Caching (and thus filling up some memory) should improve performance.

That's the only thing that I can think of at the moment...

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

No branches or pull requests

2 participants