本文包含以下内容:
1.介绍常见的获取android cpu使用率的方法
2.介绍这些常见方法背后的原理
3.介绍我自己写的一个脚本,这个脚本可以获取各个线程在cpu各个核上的占用率
一、常见的获取Android CPU使用率方法及其原理
首先说一下如何查看cpu的基本信息,相信很多人也知道,使用下面的命令即可
adb shell cat /proc/cpuinfo
比如我从手边一台电视上获取到的信息如下,可以看到是个4核CPU,还能看到对应的CPU architecture
processor : 0
BogoMIPS : 24.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: AArch64
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Hardware : Maserati
processor : 1
BogoMIPS : 24.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: AArch64
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 2
Hardware : Maserati
processor : 2
BogoMIPS : 24.00
Fe