课前准备

启动时间

Cold startup takes 5 seconds or longer.
Warm startup takes 2 seconds or longer.
Hot startup takes 1.5 seconds or longer.
07-03 20:59:24.427  1126  1696 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.xueqiu.android/.view.WelcomeActivityAlias bnds=[276,1240][540,1529]} from uid 10050
07-03 20:59:24.435 1126 1696 I ActivityManager: ActivityRecord info: ActivityInfo{3f5e7aa com.xueqiu.android.view.WelcomeActivityAlias}
07-03 20:59:24.455 1126 2640 V ActivityManager: startProcess: name=com.xueqiu.android app=null knownToBeDead=true thread=null pid=-1
07-03 20:59:24.465 1126 2640 I ActivityManager: Start proc 11962:com.xueqiu.android/u0a208 for activity com.xueqiu.android/.view.WelcomeActivityAlias
07-03 20:59:24.467 1126 2640 V ActivityManager: startProcess: name=com.xueqiu.android app=ProcessRecord{c9074d 11962:com.xueqiu.android/u0a208} knownToBeDead=true thread=null pid=11962
07-03 20:59:24.487 1126 1696 D ActivityManager: ActivityManagerService,attachApplication,callingPid = 11962
07-03 20:59:24.569 1126 1696 D ActivityManager: Skipping, home or recents stack task: TaskRecord{cb84498 #1 A=com.huawei.android.launcher U=0 StackId=0 sz=1}
07-03 20:59:24.570 1126 1696 D ActivityManager: Skipping intent:flg=0x10804000 cmp=com.android.systemui/.recents.RecentsActivity bnds=[48,1316][1032,2576]
07-03 20:59:24.570 1126 1696 D ActivityManager: Skipping intent:flg=0x10800000 cmp=com.android.systemui/.usb.HwUsbDebuggingActivity
07-03 20:59:24.570 1126 1696 D ActivityManager: Skipping intent:flg=0x18800000 hwFlg=0x100 cmp=com.huawei.hifolder/.MainProxyActivity
07-03 20:59:24.721 1126 2644 V ActivityManager: startProcess: name=com.xueqiu.android:pushservice app=null knownToBeDead=true thread=null pid=-1
07-03 20:59:24.729 1126 2644 I ActivityManager: Start proc 12038:com.xueqiu.android:pushservice/u0a208 for service com.xueqiu.android/com.xiaomi.push.service.XMPushService
07-03 20:59:24.744 1126 2644 D ActivityManager: ActivityManagerService,attachApplication,callingPid = 12038
07-03 20:59:24.789 1126 1151 I ActivityManager: Displayed com.xueqiu.android/.view.WelcomeActivityAlias: +330ms
07-03 20:59:27.749 1126 2640 I ActivityManager: START u0 {flg=0x100000 pkg=com.xueqiu.android cmp=com.xueqiu.android/.common.MainActivity} from uid 10208
07-03 20:59:27.750 1126 2640 I ActivityManager: ActivityRecord info: ActivityInfo{70b3322 com.xueqiu.android.common.MainActivity}
07-03 20:59:27.918 1126 2640 D ActivityManager: Skipping, home or recents stack task: TaskRecord{cb84498 #1 A=com.huawei.android.launcher U=0 StackId=0 sz=1}
07-03 20:59:27.918 1126 2640 D ActivityManager: Skipping intent:flg=0x10804000 cmp=com.android.systemui/.recents.RecentsActivity bnds=[48,1316][1032,2576]
07-03 20:59:27.918 1126 2640 D ActivityManager: Skipping intent:flg=0x10800000 cmp=com.android.systemui/.usb.HwUsbDebuggingActivity
07-03 20:59:27.918 1126 2640 D ActivityManager: Skipping intent:flg=0x18800000 hwFlg=0x100 cmp=com.huawei.hifolder/.MainProxyActivity
07-03 20:59:28.297 1126 1151 I ActivityManager: Displayed com.xueqiu.android/.common.MainActivity: +461ms
07-03 20:59:33.032 1126 2640 V ActivityManager: startProcess: name=com.google.android.webview:sandboxed_process0 app=null knownToBeDead=true thread=null pid=-1
07-03 20:59:33.043 1126 2640 I ActivityManager: Start proc 12210:com.google.android.webview:sandboxed_process0/u0i16 for webview_service com.xueqiu.android/org.chromium.content.app.SandboxedProcessService0
07-03 20:59:33.062 1126 2046 D ActivityManager: ActivityManagerService,attachApplication,callingPid = 12210

查看activity的创建时间

package=com.xueqiu.android
清理缓存数据:adb shell pm clear $package
停止进程:adb shell am force-stop $package
启动appadb shell am start -S -W $package/.view.WelcomeActivityAlias
获取数据:
localhost:~ seveniruby$ adb logcat |grep "Displayed "
07-03 21:08:54.054 1126 1151 I ActivityManager: Displayed com.xueqiu.android/.view.WelcomeActivityAlias: +345ms
07-03 21:08:57.542 1126 1151 I ActivityManager: Displayed com.xueqiu.android/.common.UpdateDialogActivity: +357ms (total +462ms)

录屏+拆帧

录屏

ffmpeg -i SVID_20190703_211522_1.mp4 -r 20 img-%03d.png
ffmpeg -i SVID_20190703_211522_1.mp4 -ss 00:00:09.85 -to 00:00:12.70 xueqiu.gif

手机浏览器测试

webview

性能监控系统

课后作业1

课后作业2


↙↙↙阅读原文可查看相关链接,并与作者交流