What does "I / ActivityManager: displayed ... activity ... + 850 ms" mean?

I am trying to improve the display time of my application.
I use logcat to track activity display time.

Here is a sample logcat output:

I / ActivityManager (1097): displayed com.example.myapp / com.example.myapp.activity.TutorialActivity: + 850ms (total + 1s503ms)

Can someone tell me how the work manager works, is this the time it takes to deploy activity?
What happens during this time and what takes into account this time?
And what is the difference between “normal time” and “full time”?

I tried to find materials on this subject, but failed ..

Thanks in advance!

+5
source share
1 answer

This line is printed in 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; } 

"normal time" is basically the time spent on the Activity that will be launched and the appearance of the contents of the Activity (including drawing time) will be displayed.

“total time” includes “normal time” and also takes into account the time taken to create an action stack.

Usually the "normal time" is identical to the "total time". You can see from the source code

 if (thisTime != totalTime) { sb.append(" (total "); TimeUtils.formatDuration(totalTime, sb); sb.append(")"); } 

"total time" will only be printed if it is different from "normal time".

+8
source

Source: https://habr.com/ru/post/1232533/


All Articles