Android app的理想cpu百分比 [英] Ideal cpu percent for android app

查看:253
本文介绍了Android app的理想cpu百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用adb shell来获取我的Android应用程序使用的cpu。

I used adb shell to get cpu used by my android app.

我记录了这些值,但在某些情况下我看到cpu的使用情况 - 对于我的应用程序--25%。

and I recorded these values but I see in some cases cpu usage -for my app- 25%.

我的问题是:这个值是-25%来自cpu-非常高还是什么?和Android应用程序的理想cpu%?

my question is: is this value -25% from cpu- very high or what? and what ideal cpu % for android app?

提前感谢

推荐答案

<首先要记住的是,当一个应用程序运行时,它实际上并不会在它运行的整个时间内进行计算:大部分时间它处于空闲状态,等待数据通过网络到达,或者当你正在寻找时在它的屏幕上。只有编写得非常糟糕的应用程序和游戏才能让CPU在整个运行过程中保持活动状态:这样可以非常快速地将电池耗尽,并使您的手机变得温暖。

The first thing to remember is that when an app runs, it doesn't actually do computation for the whole time it's running: most of the time it's idle, waiting for data to arrive over the network, or while you're looking at it on the screen. Only very badly-written apps and games keep the CPU active the whole time they're running: this runs the battery down very quickly, and makes your phone rather warm.

因此,即使Chrome在屏幕上显示30分钟,也不应该使用30分钟的CPU时间。如果它在那个时候是完全静态的并且你没有与之交互,它可能根本没有使用任何CPU时间!但在另一个极端,即使它不断滚动页面,也不会使用30分钟的CPU时间:屏幕每1/60秒更新一次,每次只需要运行足够长的时间才能工作下一帧应该是什么。

So even if Chrome has been on the screen for 30 minutes, it shouldn't have used 30 minutes of CPU time. If it's completely static in that time and you're not interacting with it, it might not have used any CPU time at all! But at the other extreme, even if it was continually scrolling a page, it wouldn't use 30 minutes of CPU time: the screen updates every 1/60th of a second, and each time it just has to run for long enough to work out what the next frame should be.

CPU前景

承担这一点请注意,CPU前景是应用程序在应用程序的活动位于前台时在CPU上运行的时间。 (它可能还包括来自应用程序的服务在前台的时间:即显示正在进行的通知。)它本身并不是一个非常有用的数字。

Bearing this in mind, CPU foreground is how much time the app has been running on the CPU while an activity from the app was in the foreground. (It might also include when a service from the app was in the foreground: that is, displaying an "ongoing" notification.) It's not a very useful figure on its own.

CPU总数

我相信你已经知道应用程序可以在后台运行服务和广播接收器,以及前景。 (有关详细信息,请参阅服务和广播接收器之间的区别?)CPU总数包括所有这些CPU使用情况。如果它远远超过CPU的前景,你可能会怀疑应用程序在后台做了大量的工作,因此可能是电池耗费的。 很多取决于应用程序多少钱。一个继续运行以检查某些远程服务的应用程序将在后台使用比数独游戏更多的CPU。

I'm sure you already know that apps can run services and broadcast receivers in the background, as well as activities in the foreground. (For more on this, see What's the difference between a service and a broadcast receiver? ) CPU total includes all of this CPU use. If it's a lot more than CPU foreground, you might suspect that the app is doing a lot of work in the background and therefore might be a battery hog. How much is "a lot" depends on the app. An app that keeps running to check some remote service will use more CPU in the background than a sudoku game.

保持清醒

当手机屏幕关闭时,它会开始考虑快速打盹。它进入称为睡眠的低功耗模式,其中CPU几乎完全断电直到需要。因为这可以中断应用程序的后台活动,所以应用程序可以使用唤醒锁定来停止设备进入睡眠状态,直到完成为止。 (还有另一种唤醒锁定,可以自动停止屏幕关闭。视频播放器可能会使用这种唤醒锁定。)应用程序也可以使用警报唤醒设备以执行一些后台任务。

When the screen of your phone is off, it starts to think about having a quick nap. It enters a low-power mode called sleep where the CPU is almost completely powered down until needed. Because this can interrupt apps' background activities, an app can use a wake lock to stop the device going to sleep until it's finished. (There's also another kind of wake lock, which stops the screen turning off automatically. A video player might use that kind of wake lock.) An app can also use an alarm to wake the device up to perform some background tasks.

保持清醒度量此应用程序使用唤醒锁定或警报的时间长度,以便在设备处于睡眠状态时保持设备处于唤醒状态。在某种程度上,这可能是最大的电池消耗。睡眠使用的功率比保持清醒要少得多,因此如果应用程序长时间保持唤醒锁定,它会让您的设备始终保持高功率模式,即使应用程序没有做任何有用的工作。

Keep awake measures the length of time that this app has used wake locks or alarms to keep the device awake when it would otherwise have been asleep. In a way, this is potentially the biggest drain on battery. Sleeping uses much less power than staying awake, so if an app keeps a wake lock for a long time, it's keeping your device in a high-power mode all that time, even if the app isn't doing any useful work.

如果你有一段时间的CPU使用率,然后它释放使用它在一定程度上相当不错。如果没有,您可以从上面的描述中找出高CPU使用率的情况。

If you have CPU usage to this extend for some time and then it release the usage its quite ok to some extend . If not you have identify which is your case for high CPU usage from above description .

这篇关于Android app的理想cpu百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆