线上第八期_Android 性能测试_20190519

参考资料

启动性能

startuptime(){
adb shell pm clear com.xueqiu.android
adb shell pm grant com.xueqiu.android android.permission.WRITE_EXTERNAL_STORAGE
adb shell pm grant com.xueqiu.android android.permission.READ_PHONE_STATE
adb shell pm grant com.xueqiu.android android.permission.ACCESS_FINE_LOCATION
adb shell pm grant com.xueqiu.android android.permission.ACCESS_COARSE_LOCATION
adb shell pm grant com.xueqiu.android android.permission.READ_CALENDAR
adb shell pm grant com.xueqiu.android android.permission.WRITE_CALENDAR
adb shell pm grant com.xueqiu.android android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.xueqiu.android android.permission.RECORD_AUDIO
adb shell pm grant com.xueqiu.android android.permission.CAMERA
adb shell pm grant com.xueqiu.android android.permission.REQUEST_INSTALL_PACKAGES
adb shell pm grant com.xueqiu.android android.permission.MOUNT_UNMOUNT_FILESYSTEMS
adb shell pm grant com.xueqiu.android android.permission.CALL_PHONE
adb shell am start  -W -n com.xueqiu.android/.view.WelcomeActivityAlias
adb logcat | grep -i displayed 
}



录屏

adb shell screenrecord --bugreport --time-limit 30 /data/local/tmp/xueqiu.mp4
adb pull /data/local/tmp/xueqiu.mp4 .
ffmpeg -i xueqiu.mp4  xueqiu.gif
ffmpeg -i xueqiu.mp4  frames_%05d.jpg

![](/uploads/photo/2019/2c6d809b-ead2-4fa5-ab01-758ac720c4d8.gif!large =300x)

网络性能

  • tcpdump + wireshark
  • charles mitmproxy

webview性能

  • chrome://inspect/#devices
  • timeline
  • w3c performance api

打造自己的性能测试工具或者平台

#driver.excute_script("js")
window.performance.timing.toJSON()

打印timeline以表格的形式

  // Get the first entry
  const [entry] = performance.getEntriesByType("navigation");
  // Show it in a nice table in the developer console
  console.table(entry.toJSON());

Android Studio的Profile功能

CPU Profile

MEM profile

while true; do sleep 1;adb shell input swipe $((w/2)) $((h/10*8))  $((w/2)) $((h/10*2));done

Network Profile

耗电量分析

//TODO

systrace

作业1

  • 录制自己公司的app启动过程并把gif图片上传上来

作业2

  • 使用模拟器打开自己公司的app
  • 找出其中的webview部分
  • 使用chrome devtools分析webview内容

把页面的具体性能的分析图贴到回复里

作业3

分析自己公司app的卡顿,并给出我在上面贴的那个具体某几帧的卡顿图

关闭