简体   繁体   English

IOS上的NSTimer和电池充电

[英]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 . 应用程序流程分为3大类: 上,片上片外

On-Die : Process that runs within Processor On-Die :在处理器内运行的进程

On-Chip : Process that runs in Chip, especially RAM 片上 :在芯片中运行的进程,尤其是RAM

Off-Chip : Process that runs using other hardware, such as Bluetooth, Modem, Storage, etc 片外 :使用其他硬件运行的进程,如蓝牙,调制解调器,存储等

Battery Consumption : On-Die < On-Chip < Off-Chip 电池消耗 :On-Die <On-Chip <片外

For NSTimer , it will run in On-Die & On-Chip , that will spend rather small amount of battery. 对于NSTimer ,它将在On-DieOn-Chip上运行 ,这将耗费相当少的电池。 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. NSTimer只是iOS中许多其他方法的一种方法,可以安排任务以便以后执行。 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. 链接到apple ref doc。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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