如何读取股票 CPU 使用数据

在 Ice Cream Sandwich 中,开发者选项中的一个选项是“显示 CPU 使用情况”,它在屏幕上添加了一个覆盖图(见下面的截图)。

我的问题是,我如何阅读数据?我猜测包名是当前活动的进程,但是后面的红色和绿色条是什么意思? 还有包裹上面的3个数字是什么?

enter image description here

113341 次浏览

这应该是 Unix 的平均负载。

这些数字以不同的时间间隔显示 CPU 的 一般负载。从左到右: 最后一分钟/最后五分钟/最后十五分钟

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

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

  • 我们看到的是相当于 Adb shell Dumpsys cpuinfo命令
  • 数字显示 CPU load超过1分钟,5分钟和15分钟(从左边开始)
  • Colors are showing time spent by CPU in user space (green), kernel (red) and IO interrupt (blue)

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

After a kernel patch dating back to 1993 (a 关于这个主题的深入的文章), in Linux the load average numbers no longer strictly represent the 中央处理器 load: 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 even when the system and CPUs were idle. Hence, average load numbers in Linux (Android) does not turn out to be a reliable performance metric.

更多关于「平均负载」的资料 显示 CPU 负载超过1分钟5分钟15分钟

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。平均负载为6.03意味着一个单 CPU 系统已经严重超载,但是对于一个有8个 CPU 的计算机来说还是可以的。

more info : 林克