Android:高通平台性能调试 - sheldon_blogs

时间:2024-03-04 10:50:56

Android:高通平台性能调试

1.GPU / CPU 信息打印脚本

gpu_cpu_info.bat

@echo off 
echo "==================GPU======================"
echo Used / Total:
adb shell cat /sys/class/kgsl/kgsl-3d0/gpubusy
echo Utilization rate:
adb shell cat /sys/class/kgsl/kgsl-3d0/gpu_busy_percentage
echo Max frequencies:
adb shell cat /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
echo Min frequencies:
adb shell cat /sys/class/kgsl/kgsl-3d0/devfreq/min_freq
echo Available frequencies:
adb shell cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies
echo Current frequencies:
adb shell cat /sys/class/kgsl/kgsl-3d0/devfreq/cur_freq
echo Available governors:
adb shell cat /sys/class/kgsl/kgsl-3d0/devfreq/available_governors
echo Governors:
adb shell cat /sys/class/kgsl/kgsl-3d0/devfreq/governor

echo "==================CPU======================"
echo Available frequencies:
adb shell cat
echo Max frequencies: adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo Min frequencies: adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq echo Current frequencies: adb shell cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq echo "===========================================" ping 127.0.0.1 -n 3 > nul %0 @循环执行脚本 pause

 

2.进程/线程 性能信息:

1.打印进程的堆栈信息。从堆栈信息里可以通过.so辨别哪个线程是干什么的,从而在 top -t 的结果里去查找你想要的那个线程的 CPU 使用情况。
# debuggerd -b <pid>
2.查看某个进程里所有线程 # ps -A | grep camera
cameraserver   642     1  176344  50940 binder_ioctl_write_read 0 S android.hardware.camera.provider@2.4-service_64
cameraserver   902     1   40100  18452 binder_ioctl_write_read 0 S cameraserver
# ps -T 642
USER           PID   TID  PPID     VSZ    RSS WCHAN            ADDR S CMD
cameraserver   642   642     1  176344  50940 binder_io+          0 S provider@2.4-se
cameraserver   642   718     1  176344  50940 poll_sche+          0 S provider@2.4-se
cameraserver   642   754     1  176344  50940 futex_wai+          0 S SyncManager_0
cameraserver   642   755     1  176344  50940 poll_sche+          0 S provider@2.4-se
cameraserver   642  1535     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1547     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1549     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1550     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1551     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1552     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1553     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1554     1  176344  50940 futex_wai+          0 S provider@2.4-se
cameraserver   642  1555     1  176344  50940 poll_sche+          0 S provider@2.4-se
cameraserver   642  1562     1  176344  50940 poll_sche+          0 S provider@2.4-se
cameraserver   642  1582     1  176344  50940 binder_io+          0 S HwBinder:642_1
cameraserver   642  1583     1  176344  50940 binder_io+          0 S HwBinder:642_2
cameraserver   642  1584     1  176344  50940 binder_io+          0 S HwBinder:642_3
cameraserver   642  1585     1  176344  50940 binder_io+          0 S HwBinder:642_4
cameraserver   642  4586     1  176344  50940 poll_sche+          0 S HwBinder:642_1

 查看该进程ION Buffer情况:
 # cat /sys/kernel/debug/dma_buf/dmaprocs | grep 642

provider@2.4-se (PID 642) size: 315848
dmabuf642       2544            3

3.查看线程内存占用和CPU使用率 # top 参数含义:

PID  进程号

USER 用户名

PR   优先级

NI   nice值。负值表示高优先级,正值表示低优先级m  

RES  进程使用的、未被换出的物理内存大小,单位kb 

SHR  共享内存大小,单位kb

S    进程状态。
 D=不可中断的睡眠状态
 R=运行
 S=睡眠
 T=跟踪/停止

 Z=僵尸进程

%CPU  CPU使用率 

%MEM     进程使用的物理内存百分比

TIME+    进程使用的CPU时间总计,单位1/100秒

 

4.查看指定程序(mediaserver)内存使用情况
# dumpsys meminfo mediaserver
   dumpsys [options]
             meminfo 显示内存信息
              cpuinfo 显示CPU信息
              account 显示accounts信息
              activity 显示所有的activities的信息
              window 显示键盘,窗口和它们的关系
              wifi 显示wifi信息