简体   繁体   中英

NSTimer and battery charge on IOS

I am using lots of timer in my app ..will it be reduce my battery . ? If yes how can i program with effective energy management .?

Thanks

App process is divided into 3 main categories: on-die , on-chip , and off-chip .

On-Die : Process that runs within Processor

On-Chip : Process that runs in Chip, especially RAM

Off-Chip : Process that runs using other hardware, such as Bluetooth, Modem, Storage, etc

Battery Consumption : On-Die < On-Chip < Off-Chip

For NSTimer , it will run in On-Die & On-Chip , that will spend rather small amount of battery. Depends on what is running in each timer loop, battery usage varies.

welcome to discuss.

NSTimer is just a method under many others in iOS to schedule a task for later execution. As a rule of thumb, which method you choose to schedule a task has practically no effect on your battery consumption but how often you schedule your task and what you do in your task has.

To optimize battery consumption with periodically scheduled tasks you should keep in mind:

  • Don't schedule more often than necessary
  • Do as little as possible in each run, especially for tasks that get executed frequently

You can profile your app in instrument's power consumption to zero-in the op that sucks your battery. There is a post on this topic here . Link to apple ref doc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM