zoukankan      html  css  js  c++  java
  • Android 性能测试_Monkey 实践

    转载地址:https://testerhome.com/topics/3502

    1. 针对不同APP都有什么策略还不是很清楚,比如延时、事件数量、事件比例 等设置成多少合适?

    一、运行Monkey

      1.将白名单push到手机.      

        <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">    adb push       E:1_AutomationTest1_Monkey5_NbBankwhitelist.txt data/local/tmp/</span></code>

      2.运行Monkey

      <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">adb shell
      monkey --pkg-whitelist-file /data/local/tmp/whitelist.txt --throttle 500 -s 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 15000 > /mnt/sdcard/monkey_test.txt &</span></code>

      3.根据sandman的建议,优化命令:

    <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">adb shell
    monkey --pkg-whitelist-file /data/local/tmp/whitelist.txt --throttle 500 -s 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 15000 1> /mnt/sdcard/monkey_test.txt 2>&1 &</span></code>

    2>&1的语法参考Linux的解释:http://blog.csdn.net/ithomer/article/details/9288353 

    二、内存检测

    内存检测用批处理脚本记录,约5秒记录一次:

    <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">@echo off &color 0a&setlocal enabledelayedexpansion&title %~n0
    ::@mode con lines=18 cols=50

    set package1=com.nbbank
    set package2=cn.com.spdb.mobilebank.per
    set package3=com.chinamworld.bocmbci
    set package4=com.cmbchina.ccd.pluto.cmbActivity

    adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_1.txt
    adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_2.txt
    adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_3.txt
    adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_4.txt

    :start
    adb shell dumpsys meminfo %package1% | findstr "TOTAL" >> ./meminfo_1.txt
    adb shell dumpsys meminfo %package2% | findstr "TOTAL" >> ./meminfo_2.txt
    adb shell dumpsys meminfo %package3% | findstr "TOTAL" >> ./meminfo_3.txt
    adb shell dumpsys meminfo %package4% | findstr "TOTAL" >> ./meminfo_4.txt

    echo.
    echo.
    ping -n 5 127.1>nul
    goto start</span></code>

    三、记录CPU百分比

    <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">@echo off &color 0a&setlocal enabledelayedexpansion&title %~n0
    ::@mode con lines=18 cols=50

    set package1=com.nbbank
    set package2=cn.com.spdb.mobilebank.per
    set package3=com.chinamworld.bocmbci
    set package4=com.cmbchina.ccd.pluto.cmbActivity

    adb shell top -n 1 | findstr "PID" > ./cupInfo_1.txt
    adb shell top -n 1 | findstr "PID" > ./cupInfo_2.txt
    adb shell top -n 1 | findstr "PID" > ./cupInfo_3.txt
    adb shell top -n 1 | findstr "PID" > ./cupInfo_4.txt
    :start
    adb shell top -n 1 | findstr %package1% >> ./cupInfo_1.txt
    adb shell top -n 1 | findstr %package2% >> ./cupInfo_2.txt
    adb shell top -n 1 | findstr %package3% >> ./cupInfo_3.txt
    adb shell top -n 1 | findstr %package4% >> ./cupInfo_4.txt

    echo.
    echo.
    ping -n 5 127.1>nul
    goto start</span></code>
    注意:
    命令adb shell top -n 1 | findstr %package1% 返回三行信息,暂未处理:

    <code style="font-family:Monaco, Menlo, 'Courier New', monospace;line-height:18px;display:block;border:none !important;"><span style="font-size:18px;">C:UsersStphen>adb shell top -n 1 | findstr com.nbbank
    25353 0 1% S 23 543128K 66260K bg u0_a193 com.nbbank
    25385 1 0% S 3 11480K 1368K fg u0_a193 com.nbbank
    25383 0 0% S 3 11692K 4180K fg u0_a193 com.nbbank</span></code>

    四、结果分析

     Crash、ANR、Force close暂时没发现,以后补上

    将记录的内存数据插到Excel表中对比查看

     
    • 将记录的CPU数据插到Excel表中对比查看
     
  • 相关阅读:
    Atitit  Uncaught (in promise) SyntaxError Unexpected token < in JSON at position 0
    Atitit  验证 数字验证 非空验证的最佳算法  h5
    Atitit 转移特效attilax总结
    Atitit Loading 动画效果
    Atitit 项目管理 提升开发效率的项目流程方法模型 哑铃型  橄榄型 直板型
    Atitit hibernate3 hinernate4 hibernate5新特性attilax总结
    Atitit js es5 es6新特性 attilax总结
    Atitit mybatis 3 3.2 3.3  3.4 新特性attilax总结
    Atitit spring 3.0 3.1 3.2 4.0 4.3 5.0 新特性
    Atitit jquery  1.4--v1.11  v1.12  v2.0  3.0 的新特性
  • 原文地址:https://www.cnblogs.com/d-d-w/p/10097286.html
Copyright © 2011-2022 走看看