Overview of CPU profiling

In Streamline, you can capture and analyze data from up to 6 CPU-related performance counters to help you identify inefficient functions in your code. Use the Call Paths and Functions views in Streamline to find your most expensive functions, and identify ways to optimize them.

To get a comprehensive view of how your functions behave, it is useful to take 2 captures. One using the regular time-based capture method, and one using the event-based capture method, using an event such as branch mispredictions, to sample the data. You can then compare the results to see if the functions that took the most time also caused a large number of branch mispredictions.

A time-based capture shows the percentage of time a function uses. An event-based capture shows how many times the event sample occurred in that function, as a percentage of all samples. Ideally, these 2 percentages would be almost equal. If the percentages are significantly different, it might mean that the code is triggering a microarchitecture behavior that is inefficient. For example, a function that is 5% of runtime in the time-based profile and 15% of branch mispredicts in the event-based profile. This indicates that the function has a disproportionally high number of branch mispredicts relative to its runtime. Modify the code or data to improve predictability or to avoid the branch completely, should improve performance.

Capturing data for CPU profiling

For Streamline to display your code, you must provide debug symbol information together with your application. Some game engines allow you to embed this information in the APK, and other game engines export these files separately.

You can capture data from either:

  • A debuggable Android APK with associated debug symbol files exported from a game engine or Android Studio:

    1. Install a debuggable version of the Android APK on your device and follow the normal Streamline capture process. However, you must add the debug symbol files in Streamline so that you can see the function names in the call paths and functions views.

  • A native binary of an application:

    1. Use Android Debug Bridge (adb) to install both the application and gatord on the device, then set permissions to make them executable.

    2. Run gatord and specify the application together with any input files it requires.

    3. Open Streamline and connect to the device using TCP.