Loading page

What you’ll build for runtime performance monitoring

You’ll instrument a sample application called PhotoTalk and collect the following measurements over wireless adb:

  • Inference
  • Memory
  • Temperature
  • Whole-device battery

You’ll then plot the results in JupyterLab.

In doing so, you’ll build a repeatable runtime-monitoring workflow for a LiteRT-LM application on an Arm-based Android device.

The power values that you’ll produce are battery-side estimates for the whole device. Availability depends on the counters that are exposed by the device. Use the results to investigate behavior within a run or across controlled runs, rather than as a cross-device benchmark.

Create a working directory

Start by creating a working directory to store the files that you’ll use:

    

        
        
mkdir -p "$HOME/Work"
export WORK="$HOME/Work"

    

Set the base URL for the scripts and configuration files that you’ll download:

    

        
        
export BASE_URL="https://raw.githubusercontent.com/ArmDeveloperEcosystem/arm-learning-paths/main/content/learning-paths/mobile-graphics-and-gaming/android_runtime_performance_adb"

    

Run the Learning Path commands in the same terminal session. If you need to create a new session, set WORK and BASE_URL again.

Install Android SDK

Install Java 17 and the Android command-line tools with Homebrew. Then, install the SDK packages required by PhotoTalk, including Platform Tools (which provides adb):

    

        
        
brew install --cask temurin@17 android-commandlinetools

export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
mkdir -p "$ANDROID_HOME"

android --sdk="$ANDROID_HOME" sdk install \
  platform-tools \
  "platforms;android-35" \
  "build-tools;35.0.0"

    

Accept the Android SDK licenses when prompted. The PhotoTalk revision that’s used in this Learning Path compiles against Android API level 35.

Verify the installation:

    

        
        
android --sdk="$ANDROID_HOME" sdk list
java -version
command -v adb
adb --version

    

Install Perfetto tools for profiling

Perfetto is an open-source system tracing and performance analysis platform. You’ll use Perfetto to sample PhotoTalk process memory and supported battery counters.

Trace Processor is a C++ library that loads Perfetto traces and provides an SQL interface for querying them.

Download the tool into your working directory:

    

        
        
mkdir -p "$WORK/tools/perfetto"
curl -fL https://raw.githubusercontent.com/google/perfetto/v59.0/tools/trace_processor \
  -o "$WORK/tools/perfetto/trace_processor"
chmod +x "$WORK/tools/perfetto/trace_processor"

export PERFETTO_TRACE_PROCESSOR="$WORK/tools/perfetto/trace_processor"
"$PERFETTO_TRACE_PROCESSOR" --version

    

The first invocation downloads the pinned Trace Processor binary for your macOS architecture and caches it locally.

Install Jupyter Notebook

To create a Jupyter Notebook, install JupyterLab if it’s not already installed:

    

        
        
brew install jupyterlab

    

Verify the installation:

    

        
        
jupyter --version

    

With the jupyter lab command, you can run a locally hosted web UI for developing Jupyter Notebook files. You’ll use Jupyter Notebook to create your analysis pipeline.

Install Hugging Face Hub

Install the Hugging Face Hub CLI for downloading the LiteRT-LM model:

    

        
        
brew install hf
hf version

    

What you’ve accomplished and what’s next

You’ve installed all the necessary environment tools and packages that you’ll need for runtime performance monitoring.

Next, you’ll use the Android Platform tools to wirelessly connect to a device.