UTCMenuClock icon indicating copy to clipboard operation
UTCMenuClock copied to clipboard

Adjust NSTimer to reduce CPU usage

Open davidme-stripe opened this issue 3 years ago • 0 comments

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

davidme-stripe avatar Jan 18 '23 20:01 davidme-stripe