Hed*_*deH 7 android android-logcat activity-manager
我正在努力改善应用活动的显示时间.
我正在使用logcat来跟踪我的活动显示时间.
以下是logcat输出的示例:
I/ActivityManager(1097):显示com.example.myapp/com.example.myapp.activity.TutorialActivity:+ 850ms(总计+ 1s503ms)
有人能告诉我活动经理如何得出结论,这是显示活动的时间吗?
在这段时间内会发生什么以及这段时间会考虑什么?
"正常时间"和"总时间"之间有什么区别?
我试图找到有关此事的材料,但没有成功..
提前谢谢!
shh*_*hhp 11
这一行印在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;
}
Run Code Online (Sandbox Code Playgroud)
"正常时间"基本上Activity是即将启动和Activity绘制的内容视图之间所花费的时间(包括绘图时间).
"总时间"包括"正常时间",并且还考虑了启动先前时间所花费的时间Activity.
通常,"正常时间"与"总时间"相同.您可以从源代码中看到
if (thisTime != totalTime) {
sb.append(" (total ");
TimeUtils.formatDuration(totalTime, sb);
sb.append(")");
}
Run Code Online (Sandbox Code Playgroud)
只有在与"正常时间"不同时才会打印"总时间".通常,如果在活动A中启动活动B,则活动B onCreate的"正常时间"将与"总时间"不同.
| 归档时间: |
|
| 查看次数: |
4015 次 |
| 最近记录: |