# Create a Performance Advisor report for your application

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/)
- [Set up Arm Performance Studio](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/ams/)
- [Set up an Android application for profiling](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/setup_tasks/)
- [Interpret an example Arm Streamline report](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/streamline_example/)
- [Use Arm Streamline to capture data for your application](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/streamline/)
- [View an example Performance Advisor report](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/pa_example/)
- [Create a Performance Advisor report for your application](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/pa/)
- [Analyze your application with Frame Advisor](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/fa/)
- [Debug your application with RenderDoc for Arm GPUs](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/renderdoc/)
- [Analyze shader program performance with Mali Offline Compiler](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/malioc/)
- [Next Steps](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/_next-steps/)

## Connect to Android device and collect frame data
Now that you’ve seen a [Performance Advisor example report](https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/ams/pa_example/), you can use it to capture data from your own application.

Performance Advisor runs on a Streamline capture file, so the first step is to take a capture with Streamline. Streamline must capture extra frame data from the device, which Performance Advisor needs to generate a report. To capture the extra frame data, you must first run the provided Python script, `streamline_me.py`.

This script does the following:
- Temporarily installs a daemon application on your device, called `gatord`, which Streamline uses to collect counter data.
- Temporarily installs the OpenGL ES or Vulkan layer library file on your device, which is needed to collect frame data.
- Allows you to specify options for the capture, such as whether to collect screenshots when the FPS drops below a certain threshold.

To connect to the Android device and capture frame data:
1. Open a terminal or command prompt, navigate to the Arm Performance Studio install directory and locate the `streamline_me.py` script:
   ```
   cd <installation_directory>/streamline/bin/android
   ```
2. Run the script, enabling frame boundaries, with:
   ```
   python3 streamline_me.py --lwi-mode=counters
   ```

> To see all available options, use `python3 streamline_me.py --help`.

3. The script returns a numbered list of the Android package names for the debuggable applications that are installed on your device. Enter the number of the application you want to profile.
   ```
   Searching for devices:   
   RZ8MC03VVEW / SM-A505FN found

   Select a device:
   Auto-selected RZ8MC03VVEW / SM-A505FN

   Searching for debuggable packages:
   5 debuggable packages found

   Select a debuggable packages:
   1) com.Arm.DarkArms
   2) com.UnityTechnologies.BoatAttack
   3) com.arm.malideveloper.openglessdk.occlusionculling
   4) com.arm.pa.paretrace
   5) com.sample.texturedteapot
   0) Exit script
   ```
   
The script identifies the GPU in the device, installs the daemon application and layer library, then waits for you to complete the capture in Streamline.

> Leave the terminal window open, as you need to come back to it after the capture is complete, to stop the script. When the script ends, any captured screenshots are saved to the directory you specified, and the daemon application and layer library are uninstalled from the device. Don’t unplug the device until the script has ended.

For full instructions, see the [Get started with Performance Advisor Tutorial](https://developer.arm.com/documentation/102478/latest/Run-the-streamline-me-py-script).

## Capture data with Streamline
1. Open Streamline and select the device and application on the **Start** tab.
2. Select **Start capture** to start capturing profile data from the target. Enter a name and location for the capture file that Streamline creates.
3. The application starts automatically on the device. Interact with the application as required.
4. When you’ve collected enough data, select **Stop capture**.
5. Return to your terminal, and press `ENTER` to terminate the `streamline_me.py` script.

## Generate an HTML performance report
1. In the terminal window, navigate to the location where you stored the Streamline capture file (`.apc`).
2. Run Streamline’s `streamline-cli` command with the `-pa` option on the Streamline capture file to generate the report. The default name is `report.html`.
   ```
   streamline-cli -pa <options> my_capture.apc
   ```
   For a list of available options, see [The Streamline-cli -pa command](https://developer.arm.com/documentation/102009/9-7/Command-line-options/The-Streamline-cli--pa-command) in Arm documentation, or run the following command:
   ```
   streamline-cli -pa -h
   ```
   To pass a list of options in a separate file to `streamline-cli -pa`, use:
   ```
   streamline-cli -pa <capture.apc> "@<options-file>"
   ```

## Generate a JSON performance report
This feature is particularly useful when used within a [CI workflow](https://developer.arm.com/documentation/102543).

1. In the terminal window, navigate to the location where you stored the Streamline capture file (`.apc`).
2. Run Streamline’s `streamline-cli` command with the `-pa` and `--type=json` options on the Streamline capture file to generate the report named `report.json`:
   ```
   streamline-cli -pa --type=json:report.json <other_options> my_capture.apc
   ```

## Specify performance budgets
You can specify a performance budget that is reflected in the Performance Advisor report. For more information, see [Setting performance budgets](https://developer.arm.com/documentation/102009/latest/Quick-start-guide/Setting-performance-budgets) in Arm documentation.

## What you’ve accomplished and what’s next
You’ve now generated JSON and HTML Performance Advisor reports for your application.

Next, you’ll perform frame-based analysis on your application using Frame Advisor.
