On 20 Jun 2017, at 04:04, Gerriet M. Denkmann <[email protected]> wrote:
> 
> macOS 11+
> 
> Some Cocoa app which has to do:
> 1. something a few seconds later

The main issue here isn’t energy use so much as whether you want to be able to 
cancel the operation.  If you need to be able to cancel it before it fires, 
you’ll want to use NSTimer or a CFRunLoopTimer.  Energy wise, the fact this is 
to happen “a few seconds later” would seem to imply that it isn’t going to 
happen often, so it’s probably irrelevant and which you choose is a matter of 
taste.

> 2. some other thing repeatedly about every 0.1 second.

Personally, I’d choose an API that directly supports repeating timers, so I’d 
prefer NSTimer or CFRunLoopTimer over the other options, all else being equal.  
I’d imagine that’s most likely to result in the lowest energy usage (repeated 
use of one-shot timers, it seems to me, is much more likely to result in 
dynamic memory allocation happening every time the timer fires, and it’s more 
complicated in your code because you’ll have to manage your next fire time).

Kind regards,

Alastair.

--
http://alastairs-place.net

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to