Instrumentation library for Android Cold Startup

Overview

android-cold-startup-instrumentation

This is an instrumentation library for Android Cold Startup which gives duration for each phase of App Startup.

Gradle Setup

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.okcredit:android-cold-startup-instrumentation:1.0-beta'
}

Usage

Add AppStartUpTracer.start() (at the start of onCreate) and AppStartUpTracer.stop() (at the end of onCreate) inside Application onCreate method.

override fun onCreate() {
    AppStartUpTracer.start() //Should be before super.onCreate()
    
    super.onCreate()
        ...
        ...
        ...
        

    AppStartUpTracer.stop(this) { appStartUpMetrics->
        Log.v("StartUp Logs", appStartUpMetrics.toString())
    }
}

Result

On AppStartUpTracer.stop() 2nd parameter takes a lambda which returns Startup logs at the time of the first draw which has duration for each phase during App StartUp.

AppStartUpTracer.stop(this) { appStartUpMetrics->
        Log.v("Total Time", appStartUpMetrics.totalTime.toString()) // Time Taken For Cold StartUp
        Log.v("Process Fork To CP", appStartUpMetrics.processForkToContentProvider.toString()) // Time Taken From Process start to initialising content provider
        Log.v("Content provider", appStartUpMetrics.contentProviderToAppStart.toString()) //Time Taken for initialising content providers
        Log.v("Application Create", appStartUpMetrics.applicationOnCreateTime.toString()) //Time Taken for running Application onCreate
        Log.v("First Draw", appStartUpMetrics.appOnCreateEndToFirstDraw.toString()) //Time Taken from end of Application onCreate to drawing first frame
}

Note: it gives result only post Lollipop devices(21+)

Phases of App Startup

  • Process Fork to Content Provider : Time Duration between App process forked from Zygote and First Initialization of content provider. Creating the app object and Launching the main thread will be happening here. developers have little influence on the improvement here.

  • Content Provider to App OnCreate() : Time Duration between First Initialization of the content provider to Start of App.OnCreate(). it includes All time taken for Content providers in the app.

  • App OnCreate() Start to App OnCreate() End : Time Duration between Start of App.OnCreate() to End of App.OnCreate(). it includes time taken for App.OnCreate()

  • App OnCreate() End to First Draw of the frame : Time Duration between End of App.OnCreate() to First Draw of the frame. it includes time taken for Initial activity initialisation, inflating the first layout, onMeasure() and onDraw() of for initial layout.

Screenshot 2021-07-16 at 4 38 24 PM

Acknowledgements

Thanks to py - Pierre Yves Ricau for this detailed article series about cold startup. it helps to get code snippet for this library.

License

Copyright 2021 OkCredit.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. :zap:
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. :zap:

Villains & Heroes Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information

Library to change Android launcher App Icon and App Name programmatically !

AppIconNameChanger Change Android App launcher Icon and App Name programmatically ! Download Demo APK from HERE Kindly use the following links to use

📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.
📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.

Material NavigationView for Android 📱 📱 Android Library to implement Rich, Beautiful Material Navigation View for your project with Material Design

Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

📱 AppListManager (Android Library) makes managing application and activity lists easy.
📱 AppListManager (Android Library) makes managing application and activity lists easy.

AppListManager (Android Library) AppListManager is easy to use Android library, which minimizes developing time when working on application or activit

An library to help android developers working easly with activities and fragments (Kotlin version)
An library to help android developers working easly with activities and fragments (Kotlin version)

AFM An library to help android developer working easly with activities and fragments (Kotlin) Motivation Accelerate the process and abstract the logic

Sample Project for Android Support Library 23.2
Sample Project for Android Support Library 23.2

SnapShot: Contains features Vector Drawable Animated Vector Drawable AppCompat DayNight theme Bottom Sheets Using BottomSheetDialog in day-night mode.

RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works.
RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works.

RoboDemo RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works. A sample is available in the download area of

Comments
  • Launch Response Time Tracking

    Launch Response Time Tracking

    Currently, this library only supports cold launch time. This PR would add support for cold and hot launch along with tracking multiple extra information like the first install, an update, first install after clearing data, first activity Infos, process importance, etc

    Testing Scope

    • Test result values of app launch time
    • Test in all os version
    • Test threading. Offload main thread
    opened by anjalsaneen 0
  • Metrics not getting logged when BroadcastReceiver wakes app

    Metrics not getting logged when BroadcastReceiver wakes app

    I want to measure cold startup time if app is woken from BroadcastReceiver. So steps to reproduce:

    • App is in killed state.
    • Send intent to my broadcast receiver via adb command: adb shell am broadcast bla2...
    • Result is success, the app wakes but the metrics are not getting logged like I launch the app from launcher.

    Is this expected behavior or am I missing something?

    Feature 
    opened by erick-buku 1
Releases(2.0)
Owner
OkCredit
OkCredit
The Android startup used to schedule tasks, jobs while launching Android App.

Android Startup, schedule your startup jobs Introduction AndroidStartup is an open source project used to refine your Andriod App startup. Compared wi

ShouHeng 46 Aug 24, 2022
Test android startup time fluctsdk

Test android startup time fluctsdk

Shuma Yoshioka 0 Feb 4, 2022
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs

Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs. -> you can click on headline and it will open an article of that news in the app(no need to go to chrome or any browser)

SUMIT KUMAR 5 Nov 28, 2022
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bartłomiej Klocek 60 Dec 29, 2022
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

Jacob Lim 1 Oct 28, 2021
Unity-Android-SDK-Plugins - Android SDK/Library/Plugins (aar) for Unity Developers

Unity Android SDK Plugins Unity Android SDK Plugins is an Open Source project th

NNK 1 Aug 14, 2022
Spantastic - an Android library that provides a simple and Kotlin fluent API for creating Android Spannable

Spantastic is an Android library that provides a simple and Kotlin fluent API for creating Android Spannable. This library wrappers SpannableStringBuilder and add methods to easily decorate the text with multiple spans.

Wellington Cabral da Silva 12 Nov 27, 2022
AndroidEssentials is an android library that creates helper functions for performing common tasks in Android

AndroidEssentials is an android library that creates helper functions for performing common tasks in Android such as managing preferences, managing files, showing alerts, showing toasts, checking user country & checking network connection of users. All the methods of the class are static and should be accessed directly from the AndroidEssentials class.

Isaac Sichangi 3 Jul 7, 2022