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

Adjust NSTimer to reduce CPU usage #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

davidme-stripe
Copy link

Hello! Thank you for developing UTCMenuClock, it's a very useful tool! 😄

We've noticed that when "show seconds" is disabled, the time still redraws once per second, potentially impacting battery life. This includes string drawing, XPC calls to cfprefsd, and icu date formatting.

To fix this, I've configured the NSTimer to only fire once per minute on the minute, reducing CPU usage from ~0.5% to 0%.

I also added a little bit of tolerance (~50ms) when seconds are enabled, which should allow the CPU to sleep between updates.

Before

CleanShot 2023-01-18 at 11 53 08@2x

After

CleanShot 2023-01-18 at 11 53 36@2x

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.

1 participant