# Android Vitals - How adb measures App Startup 🔎

DevFeed: [Android Vitals - How adb measures App Startup 🔎](<https://devfeed.tech/articles/android-vitals-how-adb-measures-app-startup-25855.md>)

Original publisher: [Read original article](<https://dev.to/pyricau/android-vitals-how-adb-measures-app-startup-5n7>)

Author: Py ⚔

Published: 2020-12-01T17:05:55Z

Content type: tutorial

Language: en

Sources: [Py ⚔](<https://devfeed.tech/sources/py.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [API](<https://devfeed.tech/topics/api.md>), [Code](<https://devfeed.tech/topics/code.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>)

Tags: [adb](<https://devfeed.tech/tags/adb.md>), [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [api](<https://devfeed.tech/tags/api.md>), [app-startup](<https://devfeed.tech/tags/app-startup.md>), [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [community](<https://devfeed.tech/tags/community.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [performance](<https://devfeed.tech/tags/performance.md>), [software](<https://devfeed.tech/tags/software.md>), [startup](<https://devfeed.tech/tags/startup.md>)

## AI overview

This deep dive explains how Android's ActivityTaskManager measures app startup time. The measurement runs from the system receiving an activity-start Intent until the activity window finishes drawing, using uptime before API 30 and realtime from API 30 onward. The article traces the implementation through AOSP and shows how to inspect it with Android Studio debugging.

## Source excerpt

Last week, Chet Haase published a great blog post: Testing App Startup Performance. It leverages the output of ActivityTaskManager to obtain the app startup duration. Whenever an activity starts, you'll see something like this in the logcat output: ActivityTaskManager: Displayed com.android.samples.mytest/.MainActivity: +1s380ms This duration (1,380ms in this example) represents the time that it took from launching the app to the time when the system consider it "launched," which includes drawing the first frame (hence "Displayed"). This article is a deep dive to explore the question: What does ActivityTaskManager measure exactly? I know you're impatient, let's jump to the conclusion: ActivityTaskManager measures the time (uptime on API < 30, realtime on API 30+) from when system_process receives an Intent to start an activity to when the window of that activity is done drawing. Key takeways: This measure includes a few hundred milliseconds prior to app code and resources loading, i.e. time that an app developer cannot affect. You can measure this without the extra time from within the app, I'll share how at the end. And now, let's dive into AOSP code! ActivityTaskManager log ActivityTaskManager: Displayed com.android.samples.mytest/.MainActivity: +1s380ms We know what the log looks like so we can search for it on cs.android.com: This leads us to ActivityTaskManager.logAppDisplayed(): private void logAppDisplayed(TransitionInfoSnapshot info) { StringBuilder sb = mStringBuilder; sb.setLength(0); sb.append("Displayed "); sb.append(info.launchedActivityShortComponentName); sb.append(": "); TimeUtils.formatDuration(info.windowsDrawnDelayMs, sb); Log.i(TAG, sb.toString()); } The startup duration is TransitionInfoSnapshot.windowsDrawnDelayMs. It's calculated in TransitionInfoSnapshot.notifyWindowsDrawn(): TransitionInfoSnapshot notifyWindowsDrawn( ActivityRecord r, long timestampNs ) { TransitionInfo info = getActiveTransitionInfo(r); info.mWindowsDrawnDelayMs = info.calc