AndroidProfile:使用Simpleperf测试APP中每个SO的CPU占用率

1.找到ndk路径中的simpleperf,或者到官网下载

2找到对应的二进制文件。adb push到本机中
$ adb push simpleperf /data/local/tmp

3.记录CPU使用的命令
记录进程11904的CPU,持续时间10秒。
#cd data/local/tmp
#chmod 777 simpleperf
#simpleperf record -p 11904 --duration 10
4.获取CPU的记录并展示

simpleperf report --pids 11904

4.获取展示并输出到txt

simpleperf report --pids 11904 > 1.txt

chmod 777 1.txt

5.pull 1.txt adb pull /data/local/tmp/1.txt
$ adb pull /data/local/tmp/1.txt

Ps:查看某个SO,例如我们so的CPU占用率

Report records in libsudo-game-jni.so.

$ simpleperf report --dsos /data/app/com.example.sudogame-2/lib/arm64/libsudo-game-jni.so

你可能感兴趣的:(android开发)