Monkey 稳定性测试


monkey多种参数代表的含义


参数 含义
-p 包名 代表对该程序进行压测
-–throttle 300 代表压测中延迟300毫秒
-–pct-touch 50 代表触摸时间占50%
–-pct-motion 100 代表motion(手势)事件占比
–-pct-trackball 代表滚动事件占比
--pct-rotation 滑动
--pct-pinchzoom 屏幕旋转
--pct-trackball 轨迹球事件
--pct-nav 导航事件百分比
--pct-majornav 主要导航事件百分比
--pct-anyevent 其他事件类型
--pct-syskeys 调整系统按键事件百分比
--pct-appswitch 启动activity百分比
–ignore-crashes 代表monkey运行时忽略crashes事件,继续运行
–ignore-timeouts 忽略超时
--throttle 延时毫秒
--throttle 300--randomize-throttle 设置随机时间的时间间隔区间

 


adb shell monkey -p com.htc.Weather 100 // 制定包100次
adb shell monkey -p com.htc.Weather –p com.htc.pdfreader -p com.htc.photo.widgets 100
多个包
adb shell monkey -p com.htc.Weather –v 100 日志级别0
adb shell monkey -p com.htc.Weather –v -v 100 日志级别1
adb shell monkey -p com.htc.Weather –v -v –v 100 最高级别
: -s
 用于指定伪随机数生成器的seed值,如果seed相同,则两次Monkey测试所产生的事件序列也相同的。
--throttle <毫秒>
用于指定用户操作(即事件)间的时延,单位是毫秒;
示例:adb shell monkey -p com.htc.Weather –throttle 3000 100
adb shell monkey -p com.tmall.wireless -v -v -pct-touch 50 -pct-trackball 30 -throttle 300 100
用monkey测试天猫的这个包触摸操作百分之50,轨迹球操作百分之30,其它操作百分之20,总共进行100次随机点击,事件之间间隔300ms
adb shell dumpsys cpuinfo 所有进程的cpu占有率
adb shell dumpsys cpuinfo |grep packagename 筛选你想要看的
adb shell 然后 top -m 10 -s cpu 占用cpu最高的
-t 显示进程名称,-s 按指定行排序,-n 在退出前刷新几次,-d 刷新间隔,-m 显示最大数量
adb shell dumpsys meminfo |grep packagename >/address/mem.txt 内存

monkey -p com.android.mms --throttle 1000 -s 100--ignore-crashes --ignore-timeouts --ignore-security-exceptions--ignore-native-crashes --monitor-native-crashes -v -v -v 15000 >/mnt/sdcard/monkey_test.txt 对单个apk忽略异常

--throttle<milliseconds>
在事件之间插入固定延迟。通过这个选项可以减缓 Monkey 的执行速度。如果不指定该选项,Monkey 将不会被延迟,事件将尽可能快地被产成。
示例:adb shell monkey -p com.htc.Weather –throttle 3000 100
--pct-touch<percent>
调整触摸事件的百分比(触摸事件是一个 down-up 事件,它发生在屏幕上的某单一位置)。
示例:adb shell monkey -p com.htc.Weather --pct-touch 10 1000
--pct-motion<percent>
调整动作事件的百分比(动作事件由屏幕上某处的一个 down 事件、一系列的伪随机事件和一个 up 事件组成)。
示例:adb shell monkey -p com.htc.Weather --pct-motion 20 1000
--pct-trackball<percent>
调整轨迹事件的百分比(轨迹事件由一个或几个随机的移动组成,有时还伴随有点击)。
示例:adb shell monkey -p com.htc.Weather --pct-trackball 30 1000
--pct-nav<percent>
调整“基本”导航事件的百分比(导航事件由来自方向输入设备的 up/down/left/right 组成)。
示例:adb shell monkey -p com.htc.Weather --pct-nav 40 1000
--pct-majornav<percent>
调整“主要”导航事件的百分比(这些导航事件通常引发图形界面中的动作,如:5-way键盘的中间按键、回退按键、菜单按键)
示例:adb shell monkey -p com.htc.Weather --pct-majornav 50 1000
--pct-syskeys<percent>
调整“系统”按键事件的百分比(这些按键通常被保留,由系统使用,如 Home、Back、Start Call、End Call 及音量控制键)。
示例:adb shell monkey -p com.htc.Weather --pct-syskeys 60 1000
--pct-appswitch<percent>
调整启动 Activity 的百分比。在随机间隔里,Monkey 将执行一个 startActivity() 调用,作为最大程度覆盖包中全部Activity 的一种方法。
示例:adb shell monkey -p com.htc.Weather --pct-appswitch 70 1000
--pct-anyevent<percent>
调整其它类型事件的百分比。它包罗了所有其它类型的事件,如:按键、其它不常用的设备按钮、等等。
示例:adb shell monkey -p com.htc.Weather --pct -anyevent 100 1000
指定多个类型事件的百分比:
adb shell monkey -pcom.htc.Weather --pct-anyevent 50 --pct-appswitch 50 1000
注意:各事件类型的百分比总数不能超过100%;

原文地址:https://www.cnblogs.com/lexus168/p/13939808.html