app启动测试
adb logcat
清除缓存数据:adb shell pm clear package
停止进程:adb shell am force-stop package
启动app:adb shell am start -S -W package/.startActivity
查看数据:adb logcat |grep -i displayed
录屏+ffmpeg
清除缓存数据:adb shell pm clear package
停止进程:adb shell am force-stop package
录屏:adb shell screenrecord --bugreport --time-limit 30 /data/local/tmp/test.mp4 &
下载到本地:adb pull /data/local/tmp/test.mp4 /Users/Documents/
拆帧:ffmpeg -i test.mp4 -r 10 frame_03%d.png
耗电量测试
安装
git clone https://github.com/google/battery-historian.git
cd battery-historian
go get -d -u github.com/google/battery-historian...
go run setup.go(20190513)
go run cmd/battery-historian/battery-historian.go
收集数据
1、清理耗电量数据
adb shell dumpsys batterystats --reset
adb shell dumpsys batterystats --enable full-wake-history
2、运行测试用例
3、收集数据
android7:adb bugreport bugreport.zip
android6:adb bugreport>bugreport.txt
4、打开localhost:9999
指标含义
battery_level:电量
plugged:充电状态以及充电时长
screen:屏幕是否点亮
top:显示当前手机运行的app
status:电池状态信息
cpu占用测试
proc时间片测试
获取当前系统的时间片:adb shell cat /proc/stat
获取app应用在手机上的pid:adb shell ps -A (Android高版本需要加-A)
获取进程的时间片:adb shell cat /proc/7785/stat| awk -F" " '{print 15}'
cpu usage = utime+stime(当前时间点)-utime+stime(旧时间点)/ total cpu Jiffies*内核数
获取手机内核数:
top获取cpu占用
adb shell top -n 1| grep PackageName
内存测试
手机总运行内存:adb shell cat /proc/meminfo |grep MemTotal
获取VSS RSS:adb shell top -n 1 |grep "packageinfo"
获取PSS:adb shell dumpsys meminfo pakagename
自动遍历技术
monkey
adb shell monkey 100 对所有包进行随机100个事件
adb shell monkey -p package 100 对某个包进行随机100个事件
adb shell monkey -p package -s 20 100 时间种子,用来回放
adb shell monkey -p package -s 20 -vv 100 详细日志
adb shell monkey -p package --throttle 1000 100 每个事件的间隔
adb shell monkey -p monkey --pct-touch 10 100 事件百分比
monkey常用事件
--pct-touch 触摸事件,比如点击
--pct-motion 滑动事件
--pct-trackball 轨迹事件,比如点击+滑动
--pct-majornav 主要导航事件