Java教程

APP性能测试-启动时间

本文主要是介绍APP性能测试-启动时间,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.冷启动

冷启动:后台没有该应用程序的进程,应用首次启动。

获取package名

打开APP,然后使用命令

adb shell dumpsys activity | grep mFocusedActivity

adb shell logcat | grep START

adb shell logcat | grep cmp=

 

adb shell dumpsys activity | findstr mFocusedActivity
  mFocusedActivity: ActivityRecord{6468932 u0 com.android.contacts/.activities.PeopleActivity t156}

 

adb shell logcat | findstr START
03-09 22:45:57.809  1637  2939 E ActivityTaskManager: START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10600000 hwFlg=0x10 cmp=com.lingkou.leetcode/com.lingkou.main.splash.SplashActivity bnds=[648,1619][858,1968] (has extras)} result: 2

 

启动APP:

adb shell am start -W -n <package/activity>

adb shell am start -W -n com.android.contacts/.activities.PeopleActivity

Starting: Intent { cmp=com.android.contacts/.activities.PeopleActivity }
Status: ok
Activity: com.android.contacts/.activities.PeopleActivity
ThisTime: 334
TotalTime: 334
WaitTime: 375
Complete

 

停止APP:

adb shell am force-stop package

 

2.热启动

热启动:后台已经有了该程序的进程(返回,home键退出让应用程序在后台继续执行)当再次点开APP马上能够恢复到上次使用的状态,不需要再回到手机的首页打开应用程序。

 

adb shell input keyevent 3(home键)

adb shell input keyevent 4(返回)

 

参考:

https://blog.csdn.net/gufenchen/article/details/91410667

https://www.cnblogs.com/zhangwei-qianqian/p/11887627.html

https://blog.csdn.net/h_bpdwn/article/details/91425599

这篇关于APP性能测试-启动时间的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!