adb 命令
C:\Users\tdx>adb shell am start -W com.test.Android/com.test.Android.AndroidActivity
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.tdx.AndroidNewTAPP/com.tdx.Android.TdxAndroidActivity }
Status: ok
LaunchState: COLD
Activity: com.tdx.AndroidNewTAPP/com.tdx.Android.TdxAndroidActivity
TotalTime: 2783
WaitTime: 2790
Complete
查看系统打印
2022-02-14 09:38:59.610 1725-1773/? I/ActivityTaskManager: Displayed com.test.Android/com.test.Android.AndroidActivity: +2s724ms
详细耗时打点
方法打点耗时
JakeWharton/hugo: Annotation-triggered method call logging for your debug builds. (github.com)
public class TraceHelper {
private Map<String,Long> timeMap = new HashMap<>();
private TraceHelper(){}
public static TraceHelper getInstance(){
return ViewHolder.instance;
}
/**
* 保存初始时间
* @param tag
*/
public void setStartTime(String tag){
timeMap.put(tag,System.currentTimeMillis());
}
/**
* 计算耗时
* @param tag
*/
public void computeTime(String tag){
if (timeMap.containsKey(tag)){
long useTime = System.currentTimeMillis() - timeMap.get(tag);
tdxLogOut.i("TraceHelper", tag + " +开启耗时+ " + useTime + "ms");
}
}
private static class ViewHolder{
private static TraceHelper instance = new TraceHelper();
}
}
网友评论