What does “I/ActivityManager: Displayed…activity…+850ms” comprised of?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


What does “I/ActivityManager: Displayed…activity…+850ms” comprised of?



I'm trying to improve display time of my app's activity.
I'm using logcat to track my activity display time.

Here is an example of a logcat output:

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



Can someone tell me how does the activity manager concludes this is the time takes to diplay the activity?
What happens during this time and what does this time takes into account?
And what is the difference between the "normal time" and "total time"?



I tried to find materials on the matter but no success..

Thank's in advance!




1 Answer
1



This line is printed in com.android.server.am.ActivityRecord.reportLaunchTimeLocked:


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 between the Activity is about to be launched and the content view of the Activity is drawn (includes drawing time).


Activity


Activity



"total time" includes "normal time" and also takes into account the time spent to launch previous Activitys.


Activity



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


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



the "total time" will be printed only when it is different from "normal time". Usually, If Activity B is launched in onCreate of Activity A, the "normal time" of Activity B will be different from "total time".


onCreate






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name