此行打印在com.android.server.am.ActivityRecord.reportLaunchTimeLocked
:
private void reportLaunchTimeLocked(final long curTime) {
final ActivityStack stack = task.stack;
final long thisTime = curTime - displayStartTime;
final long totalTime = stack.mLaunchStartTime != 0
? (curTime - stack.mLaunchStartTime) : thisTime;
if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching", 0);
EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME,
userId, System.identityHashCode(this), shortComponentName,
thisTime, totalTime);
StringBuilder sb = service.mStringBuilder;
sb.setLength(0);
sb.append("Displayed ");
sb.append(shortComponentName);
sb.append(": ");
TimeUtils.formatDuration(thisTime, sb);
if (thisTime != totalTime) {
sb.append(" (total ");
TimeUtils.formatDuration(totalTime, sb);
sb.append(")");
}
Log.i(ActivityManagerService.TAG, sb.toString());
}
mStackSupervisor.reportActivityLaunchedLocked(false, this, thisTime, totalTime);
if (totalTime > 0) {
//service.mUsageStatsService.noteLaunchTime(realActivity, (int)totalTime);
}
displayStartTime = 0;
stack.mLaunchStartTime = 0;
}
“正常时间”基本上Activity
是在即将启动和绘制内容视图之间所花费的时间Activity
(包括绘制时间)。
“总时间”包括“正常时间”,还考虑了启动前一个Activity
s所花费的时间。
通常,“正常时间”与“总时间”相同。从源码中可以看到
if (thisTime != totalTime) {
sb.append(" (total ");
TimeUtils.formatDuration(totalTime, sb);
sb.append(")");
}
只有当它与“正常时间”不同时才会打印“总时间”。通常,如果在Activity A中启动了Activity B,则Activity BonCreate
的“正常时间”会与“总时间”不同。