This tutorial describes how to use Streamline to capture a profile of a debuggable application running on an unrooted Android device with a  MaliTM GPU. Follow the steps in each section to set up your environment, connect to the target device and capture a profile to analyze.

This video provides a walkthrough of these steps:

Choose Next to browse through the steps as you work through them, or choose Single Page to view all the steps on one page.

Before you begin

On your host machine:

  1. Download and install the Arm Mobile Studio package appropriate to your host platform (Windows, Linux, or macOS).
  2. Install Python 3.5 (or higher). You will need this to run the provided gator_me.py script, which uses the gatord agent to connect Streamline to your Android target.
  3. Install Android Debug Bridge (ADB). ADB is available with the Android SDK platform tools, which are installed as part of Android Studio, or you can download them separately here.
  4. Edit your PATH environment variable to add the paths to the Python3 directory and the Android SDK platform tools directory. 

Configure your device

On your device:

  1. Ensure Developer Mode is enabled, then enable USB Debugging using Settings > Developer options.
  2. Connect the target to the host through USB. 
  3. Run the adb devices command on the host to check that connection is successful. If successful, this command returns the ID of your target.
    adb devices
    List of devices attached
    ce12345abcdf1a1234       device
    You should also be able to run adb shell without issues.
  4. Install a debuggable application:
    • For Unity applications, select the Development Build option in Unity's Build Settings when building your application.
    • If you're not using Unity, ensure your application is marked as debuggable in the Android application manifest (see more on how to do this in the Android Studio documentation).

Connect Streamline to your device

Arm provides a Python script, gator_me.py that installs a daemon, gatord, on your device. Streamline uses this daemon to connect to unrooted Android devices and collect data. Follow these steps to run the script so that Streamline can communicate with your device.

  1. On your host machine, navigate to the Streamline installation directory, <install_dir>/streamline/gator/ where you will find the gator_me.py script.
  2. Run the gator_me.py script with the --daemon option, to supply the path to the gatord binary that will be installed on the device. For example:
    python3 gator_me.py --daemon ../bin/arm64/gatord
    There are two versions of the gatord, for 32-bit or 64-bit architectures, located in the following directories:
    • <install_dir>/streamline/bin/arm64/ for Armv8 64-bit architectures.
    • <install_dir>/streamline/bin/arm/ for 32-bit architectures.
  3. The script will return a numbered list of the Android package names for the debuggable applications that are installed on your device. Enter the number of the package you want to profile.

    Alternatively, if you know the Android package name of the app you want to profile you can specify it when running the script, using the --package option.

    python3 gator_me.py --package com.mycompany.myapp --daemon ../bin/arm64/gatord

    IMPORTANT: When you've finished capturing data from this device, switch back to the terminal running the gator_me.py script and press any key to terminate it. The script kills all processes that it started and removes gatord from the target.

  4. Launch Streamline:
    1. On Windows, from the Start menu, navigate to the Arm Mobile Studio folder, and select the Streamline shortcut.
    2. On macOS, go to the <install_dir>/streamline folder, and double-click the Streamline.app file.
    3. On Linux, go to the <install_dir>/streamline folder, and run the Streamline file:
      cd <install_dir>/streamline
  5. Use the Start tab in Streamline to select your device. Select Or, choose an existing target, then select your device from the list.
    Connect to your device in Streamline
  6. Before starting the capture, choose Configure Counters to choose a counter template.

Choose a counter template

Counter templates are pre-defined sets of performance counters that enable you to perform an initial performance review of how the CPU and GPU behave when you run your application. Choose the most appropriate template for the GPU in your target device.

  1. From the Target tab, open the Counter configuration dialog by selecting the button.
    Choose counter configuration in Streamline
  2. Choose Add counters from a template Add counters from a template button to see the list of available templates. 

    Streamline's counter configuration dialog
  3. Choose a counter template appropriate for the target GPU in your target device. The number of counters in the template that your target device supports is shown next to each template. For example, here, 34 of the 38 available counters in the Mali Midgard template are supported in the connected device. 
    Choosing a counter template in Streamline

    For detailed descriptions of all of the available counters for each Mali GPU, refer to the Mali GPU counter reference.

  4. Save your changes.
  5. Optionally, select the Capture and Analysis options button from the Target tab, to set additional capture options, including the sample rate and the capture duration. Refer to Capture options in the Arm Streamline User Guide for more details.

Capture a profile

  1. Select Start Capture.
    Streamline start capture button
  2. Specify the name and location of the capture file that Streamline will create when the capture is complete. Streamline then switches to Live view and waits for you to start the application on the device.
  3. Start the application you want to profile. Live view shows charts for each counter that you selected. Below the charts is a list of running processes in your application with their CPU usage. The charts now start updating in real time to show the data that gatord captures from your running application:
  4. Unless you specified a capture duration, click Stop capture to end the capture . Arm Streamline stores the capture file in the location you specified previously and then prepares the capture for analysis. When complete, the capture appears in the Timeline view.
  5. IMPORTANT: Switch back to the terminal running the gator_me.py script and press any key to terminate it. The script kills all processes that it started and removes gatord from the target.
  6. Select the Switch and manage templates button  and select the same counter configuration template that you chose to create the capture.
    Select the counter template for your target GPU

Analyze your capture

Analyze the data in Streamline's Timeline view to see how the GPU and CPU in the device handled your application. The charts area is populated with the performance counter activity for the counters in the selected template. Below the charts area is the details panel, which provides further metrics from your capture. Both the charts and details panel are aligned on the timeline.

For detailed descriptions of all of the available counters for each Mali GPU, refer to the Mali GPU counter reference.

  1. Control the granularity of the data by selecting the time unit. For example, if you choose 50ms, every color-coded unit in the details panel represents data captured during a 50ms window.
  2. Hover over a chart to see the values at that point on the timeline.
    Hover over a chart in Streamline to see the values
  3. Click anywhere on the timeline and drag the handles on the cross-section marker to select a range of time to investigate more closely. The information shown in the details panel when in Processes and Samples modes updates to show data for the window of time you have defined.
    Cross-section marker

    Note: If you define a region of time with the Cross-section marker, then change the view to a larger time unit where the Cross-section marker border cannot sit precisely, the border is displayed as a blurred line.

  4. Unlike the filter controls, moving and expanding the Cross-section marker does not affect the data in the other report views. To do this, use the calipers to set the required time region. Drag the calipers to the required time region, or right-click on the timeline and select Set Left Caliper or Set Right Caliper. When you move the calipers, the Call Paths, Functions, and Code views update to show information for the selected region. 
    Select a time region with the calipers

For more information about how to analyze performance with Arm Streamline, see Analyze your capture in the Arm Streamline User Guide.

Disconnect Streamline from your target

  1. IMPORTANT: On the host, switch back to the terminal running the gator_me.py script and press any key to terminate the script. The script kills all processes that it started and removes gatord from the target.
  2. Unplug your device from your host machine.