您在开发移动应用程序时修复了哪些由于能源效率低下问题而导致的错误

发布于 2024-10-06 04:09:03 字数 1431 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦幻的心爱 2024-10-13 04:09:03

首先回答后续问题,很少有客户注意到使用特定应用程序在能源效率或电池寿命方面有任何差异。 App Store 评论中几乎从未提及这一点。我编写节能代码主要是因为我不想在测试和使用我的应用程序时耗尽自己设备的电池。

针对 iPhone 应用程序的一些建议:

  1. 编写应用程序,使其能够在最慢的操作系统(3G 上为 4.x)的最慢设备(iPhone 2G 或 3G)上正常运行。然后它就可以在速度更快的当前设备上处于空闲状态。

  2. 在图形例程中,尽量不要重绘任何已经绘制的内容。使用小型 CALayer 或子视图进行本地化图形更新/更改。

  3. 尽可能多地使用异步方法,这样您的应用大部分时间都不会在 CPU 上运行。

  4. 如果可能的话,使用纯 C 数据结构(而不​​是 Foundation 对象)并将它们打包,以便应用程序的工作集可以完全驻留在非常有限的 ARM CPU 数据缓存中。

  5. 不要进行不必要的网络活动。一次尽可能进行最大的数据传输,以便无线电可以在应用程序的网络使用之间关闭更长时间,而不是进行大量连续的小规模传输。

To answer the follow-up question first, very few customers notice any difference in energy efficiency or battery life from using a particular app. This is almost never mentioned in the App store reviews. I write power efficient code mostly because I don't want to run down my own device's batteries while testing and using my apps.

Some suggestions for iPhone apps:

  1. Write your app so that it runs well on the slowest device (iPhone 2G or 3G) with the slowest OS (4.x on a 3G). Then it can mostly be idle on the much faster current devices.

  2. In graphics routines, try not to redraw anything already drawn. Use a small CALayer or sub view for localized graphics updates/changes.

  3. Use async methods as much as possible so that your app isn't even running on the CPU most of the time.

  4. Use plain C data structures (instead of Foundation objects) and pack them so that your app's working set can stay completely resident in the very limited ARM CPU data cache, if possible.

  5. Don't do networking any more than necessary. Do the largest data transfers possible at one time so that the radios can turn off longer between your app's network use, instead of lots of continuous small transfers.

天荒地未老 2024-10-13 04:09:03

移动开发中的能源效率等同于嵌入式系统中的内存限制。

具体来说,我喜欢 GPS 应用程序,因此请确保 GPS 仅在最短的时间内打开。当然,当出现导致 GPS 开启时间过长的错误时,它们会转到列表顶部进行修复。

因此,简短的回答是:是的,能源效率绝对与功能一样重要。

Energy efficiency in mobile dev is tantamount to memory constraints in embedded systems.

Specifically, I like GPS apps and so make sure that the GPS is only on for the bare minimum of time. Of course, when there are bugs that are introduced that keep the GPS turned on too long they go to the top of the list to get fixed.

So, the short answer is: Yes, energy efficiency is definitely as important as features.

如果没有 2024-10-13 04:09:03

EE 非常重要,尤其是当应用程序在后台持续运行时。

我们必须尽可能用基于事件的方法替换轮询方法。如果不可能,我们会降低投票频率。

此外,将文件读取/写入减少到最低限度也可大大减少电池消耗。

EE is important especially if the application is running constantly in the background.

We had to replace polling methods with event based methods whenever possible. If it was not possible we reduced the polling frequency.

Also reducing file read/writes to minimum reduces battery consumption considerably.

囚我心虐我身 2024-10-13 04:09:03
  1. 对于低 cpu 手机,在服务器上处理图像 + 计算,而不是使用手机 cpu(不适用于 iPhone + Android 手机)
  2. 仅在必要时绘制到屏幕,而不是无休止地绘制到屏幕
  3. 始终保存状态,以便用户可以进入应用程序如果中断导致您的应用程序被置于后台,它们就会停止运行
  4. 尽可能避免在后台运行?您是否确实需要或可以等到应用程序获得焦点
  5. 避免使用粗粒度位置(GPS 与蜂窝位置)
  6. 在可以节省轮询网络的情况下使用推拉
  1. Process images + calculations on the server for low cpu phones rather than using the phones cpu (not as applicable on iPhone + Android handsets)
  2. Draw to the screen only when necessary rather than endlessly
  3. Save state at all times so the user can enter the application where they left off if an interrupt causes your application to be placed into the background
  4. Avoid running in the background where ever possible? do you really need to or can wait until the application has focus
  5. Avoid using fine grain location where a coarse location would do (GPS vs cellular location)
  6. Use push over pull where ever it is possible to save polling the network
花开半夏魅人心 2024-10-13 04:09:03

在我的基于 opengl 的动态壁纸中,电池寿命是一个重要问题。

将传感器的使用保持在最低限度,有很多不同的配置文件,请使用您需要的延迟。

为了最大化 LWP 中的电池,我通常默认将帧延迟强制为 5 毫秒。这似乎足以让 CPU 在帧之间放松并保持相当低的使用率。您还可以根据当前 FPS 管理超时并将其固定到 FPS 配置文件。例如,设备可以渲染 60 fps,但您只是以 30 fps 渲染,并且一半时间在睡觉。

对于游戏,您可以执行相同的操作,只需在引擎中设置 fps 限制,并且不要让它超出该限制。

如果您想成为硬核,请注意,许多 Android 设备中使用的 OLED 需要更多电量来显示浅色,而不是深色。 LCD 上有相同的背光,但 OLED 上的黑色像素实际上处于关闭状态并且不使用电源。因此,屏幕越暗,电池续航时间就越长。如果你想在电池方面做到真正的核心,那么在某些情况下需要考虑一些事情。

不要使用 GPS,不要使用 3G,如果你确实在本地缓存所有内容。

In my opengl based live wallpapers battery life is a significant issue.

Keep sensor use to a minimum, there is lots of different profiles, use the delay that you require.

To maximize battery in a LWP I usually force a frame delay of 5ms by default. This appears to be enough time to let the CPU relax between frames and keep the usage reasonably low. You can also manage the timeout based on the current FPS and pin it to a FPS profile. E.g. the device could render 60fps, but you are just rendering at 30fps and sleeping half the time.

For games you could do the same, just put a fps limit in your engine and don't let it go above that.

If you want to be hardcore, realize that OLED's used in many android devices use more power to display light colors as opposed to dark ones. On a LCD there is a equal backlight, but on OLED a black pixel is effectively off and not using power. So the darker your screen, the longer your battery life should last. Something to consider in certain situations if you want to be really hardcore on the battery side of things.

Don't use the GPS, don't use 3G, and if you do cache everything locally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文