Android 如何读取 Stock CPU Usage 数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10829546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:07:32  来源:igfitidea点击:

How to read the Stock CPU Usage data

androidcpu-usage

提问by XGouchet

On Ice Cream Sandwich, an option in the Developer Options is "Show CPU Usage", which adds an overlay on the screen (see screenshot below).

在冰淇淋三明治上,开发人员选项中的一个选项是“显示 CPU 使用情况”,它会在屏幕上添加一个叠加层(参见下面的屏幕截图)。

My question is, how do I read the data ? I guessed that the package names are the process currently actives, but what does the red and green bars behind mean ? Also what are the 3 numbers on top of the packages ?

我的问题是,如何读取数据?我猜包名称是当前活动的进程,但后面的红色和绿色条是什么意思?另外,包装上的 3 个数字是多少?

enter image description here

在此处输入图片说明

采纳答案by nkr

This should be the Unix load average. Wikipediahas a nice article about this.

这应该是 Unix 平均负载。维基百科有一篇关于这个的好文章。

The numbers show the averageload of the CPU in different time intervals. From left to right: last minute/last five minutes/last fifteen minutes

数字显示了不同时间间隔内 CPU的平均负载。从左到右:最后一分钟/最后五分钟/最后十五分钟

回答by Vaiden

So far this has been the most helpful source of information regarding this I could find. Apparently the numbers do NOT reperesent load average in %: http://forum.xda-developers.com/showthread.php?t=1495763

到目前为止,这是我能找到的最有用的信息来源。显然这些数字不代表负载平均百分比:http: //forum.xda-developers.com/showthread.php?t=1495763

回答by Slider2k

As other answers have pointed, on UNIX systems the numbers represent CPU load averagesover 1/5/15 minute periods. But on Linux (and consequently Android), what it represents is something different.

正如其他答案所指出的那样,在 UNIX 系统上,这些数字代表1/5/15 分钟周期内的CPU 负载平均值。但是在 Linux(以及 Android)上,它代表的东西是不同的。

After a kernel patch dating back to 1993 (a great in-depth article on the subject), in Linux the load average numbers no longer strictly represent the CPUload: as the calculation accounts not only for CPU bound processes, but also for processes in uninterruptible wait state - the original goal was to account for I/O bound processes this way, to represent more of a "system load" than just CPU load. The issue is that since 1993 the usage of uninterruptible state has grown in Linux kernel, and it no longer typically represents an I/O bound process. The problem is further exacerbated by some Linux devs using uninterruptible waits as an easy wait to avoid accommodating signals in their implementations. As a result, in Linux (and Android) we can see skewed high load average numbers that do not objectively represent the real load. There are Android user reports about unreasonable high load averages contrasting low CPU utilization. For example, my old Android phone (with 2 CPU cores) normally shown average load of ~12 when when the system and CPUs were idle. Hence, average load numbers in Linux (Android) does not turn out to be a reliable performance metric.

在一个可追溯到 1993 年的内核补丁(一篇关于该主题的深度文章)之后,在 Linux 中,平均负载数字不再严格代表CPU负载:因为计算不仅考虑了 CPU 绑定进程,还考虑了处于不间断等待状态的进程 - 最初的目标是以这种方式考虑 I/O 绑定进程,以表示更多的“系统负载”而不仅仅是 CPU 负载. 问题是自 1993 年以来,不间断状态在 Linux 内核中的使用有所增长,并且它不再通常代表 I/O 绑定进程。一些 Linux 开发人员使用不间断等待作为避免在其实现中容纳信号的简单等待,从而进一步加剧了该问题。因此,在 Linux(和 Android)中,我们可以看到不客观地代表真实负载的偏高平均负载数字。有 Android 用户报告称不合理的高平均负载与低 CPU 利用率形成对比。例如,当系统和 CPU 空闲时,我的旧 Android 手机(具有 2 个 CPU 内核)通常显示约 12 的平均负载。因此,Linux (Android) 中的平均负载数并不是一个可靠的性能指标。

回答by j-shan huang

More about "load average" showing CPU load over 1 minute, 5 minutes and 15 minutes

有关“平均负载”的更多信息,显示 1 分钟、5 分钟和 15 分钟内的 CPU 负载

Linux, Mac, and other Unix-like systems display “load average” numbers. These numbers tell you how busy your system's CPU, disk, and other resources are. They're not self-explanatory at first, but it's easy to become familiar with them.

Linux、Mac 和其他类 Unix 系统显示“平均负载”数字。这些数字告诉您系统的 CPU、磁盘和其他资源的繁忙程度。一开始它们并不一目了然,但很容易熟悉它们。

WIKI: example, one can interpret a load average of "1.73 0.60 7.98" on a single-CPU system as:

during the last minute, the system was overloaded by 73% on average (1.73 runnable processes, so that 0.73 processes had to wait for a turn for a single CPU system on average).
during the last 5 minutes, the CPU was idling 40% of the time on average.
during the last 15 minutes, the system was overloaded 698% on average (7.98 runnable processes, so that 6.98 processes had to wait for a turn for a single CPU system on average) if dual core mean: 798% - 200% = 598%. 

You probably have a system with multiple CPUs or a multi-core CPU. The load average numbers work a bit differently on such a system. For example, if you have a load average of 2 on a single-CPU system, this means your system was overloaded by 100 percent — the entire period of time, one process was using the CPU while one other process was waiting. On a system with two CPUs, this would be complete usage — two different processes were using two different CPUs the entire time. On a system with four CPUs, this would be half usage — two processes were using two CPUs, while two CPUs were sitting idle.

您可能有一个带有多个 CPU 或多核 CPU 的系统。在这样的系统上,平均负载数字的工作方式略有不同。例如,如果您在单 CPU 系统上的平均负载为 2,这意味着您的系统过载了 100% — 整个时间段内,一个进程在使用 CPU,而另一个进程在等待。在具有两个 CPU 的系统上,这将是完全使用——两个不同的进程一直在使用两个不同的 CPU。在具有四个 CPU 的系统上,这将是一半的使用率——两个进程使用两个 CPU,而两个 CPU 闲置。

To understand the load average number, you need to know how many CPUs your system has. A load average of 6.03 would indicate a system with a single CPU was massively overloaded, but it would be fine on a computer with 8 CPUs.

要了解平均负载数,您需要知道您的系统有多少 CPU。平均负载为 6.03 表示具有单个 CPU 的系统严重过载,但在具有 8 个 CPU 的计算机上没有问题。

more info : Link

更多信息:链接

回答by SeeR

From High Performance Android Appsbook (page 157):

来自高性能 Android 应用程序一书(第 157 页):

  • what we see is equivalent of adb shell dumpsys cpuinfocommand
  • Numbers are showing CPU loadover 1 minute, 5 minutes and 15 minutes (from the left)
  • Colors are showing time spent by CPU in user space (green), kernel (red) and IO interrupt (blue)
  • 我们看到的相当于adb shell dumpsys cpuinfo命令
  • 数字显示1 分钟、5 分钟和 15 分钟内的CPU 负载(从左侧开始)
  • 颜色显示 CPU 在用户空间(绿色)、内核(红色)和 IO 中断(蓝色)中花费的时间