Understanding Android App performance

We took one of the open-source weather app to analyze the performance. This particular app contains all the metrics related to startup time, method trace, and API monitoring.

Start-up time:

Implementation: Ideally, to calculate cold start we must track the starting point from the time when the app intent is launched. But since we cannot track from the process creation stage from a developer’s point of view, we start tracking as soon as the content provider from the manifest is initialized. This becomes the earliest point of detection for an app start.

Syntax: You do not need to add any code from the SDK since this is monitored from the background.

Image for post
Image for post

The start-up time metrics indicate the amount of time taken to complete a cold and warm start.

  • Cold start can be defined as the time taken for the app to start from scratch and does not reside in memory. This is even before the initial process is created.
  • Warm start is when the user exits the app and re-launches it. In this case, the app does not reside in memory.

The data recorded is in milliseconds and the warm start values can vary upon different launches. According to Android Vitals, your app’s startup times are excessive when

  • Cold start takes 5 seconds or longer.
  • Warm start takes 2 seconds or longer.

API calls:

Implementation: API calls can be monitored for two cases being Retrofit calls and OkHttp calls only. For both, we would require to call some methods from the Perfachhi SDK.

To monitor OkHttp calls, we must pass the call object to the execute method which will be called from the SDK.

Example :

To monitor Retrofit calls, we simply need to attach a Retrofit Interceptor from the SDK which will do the monitoring work for you. You would just have to create a okHttp client like always and attach it to Retrofit Interceptor to it. Then you can add the client to Retrofit and you are good to go.

Image for post
Image for post
Image for post
Image for post

As far as API calls are concerned, we can monitor them for two separate cases. Applications that use Retrofit and the applications that use OkHttp only.

For apps that use retrofit, we need to attach a Retrofit Interceptor to the okHttp client which will then be used by Retrofit. So now every time a retrofit call is made from the service, the API calls following from that service will be captured and various details will be extracted.

The extracted details are: Type of method, response code, time taken for the request to complete, and the content type.

App details:

The app that is under test is a news application that uses Retrofit to make queries to an online news API. This fetches a bunch of articles that are laid down in a recycler view using architectural components.

Multiple methods were put for the trace to monitor how they take to complete (Method Trace). We have also included screen transitions for different activities that will tell you how long it took to transition from one activity to the other.

The SDK integrated with this app also gives information like Network Usage, API calls, Screenshots, Screen Transitions, Method Trace, GCs, and Memory leaks.

Report details:

The SDK was integrated with a weather application for android but we did not have Retrofit support for that. We were able to generate reports which comprised of all the other parameters.

The app that you see here is a news application built using architectural components.

Image for post
Image for post

The above image depicts the analysis for frame drops with a graph. This pinpoints the frame rate at each position and slowly starts indicating with different warning colors if your frame drops below 50.

Image for post
Image for post

The network usage section demonstrates how much data has been sent and received at a particular point in time. The overall usage is laid out in the form of a graph which makes it easier for us to understand this metric.

Image for post
Image for post

The method trace section indicates the time taken for each method to get executed. You can trace different methods by adding a line of code indicating the starting and ending point of the trace. Here as you can see the “LoadJson Trace” is taking about 72ms to execute.

Image for post
Image for post

The screen transition metric gives you details as to how long it took to transition to a specific activity. As you can see the Details activity takes about 293ms to transition to which tells us that this is something to be looked at.

Getting such details across devices with tools like Android studio or Firebase is difficult due to device restrictions, setup, and data in a huge volume. Perfachhi makes it easier to capture all such data and visualize to understand the flow with performance parameters pinned to it.

Written by

A pre-prod performance monitoring tool for Android developers. We will talk more about app performance and how can you optimize the app performance. Follow us!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store