Skip to main content

CLI tool for running memory latency benchmarks on Android devices

Project description

BenchmarkingCLI

A command-line tool for running latency benchmarks on Android devices. This tool automates the process of pushing benchmark binaries to connected Android devices, executing latency tests, and collecting performance metrics in CSV format.

Features

  • Latency Testing: Measure memory latency across different buffer sizes on a specific core
  • Loaded Latency Testing: Measure latency under load while bandwidth threads are concurrently running
  • Kernel Mode Selection: Choose between SUM, COPY, UPDATE, and TRIAD bandwidth kernels
  • Automated Device Management: Automatic ADB device detection and binary deployment
  • CSV Export: Results are automatically parsed and exported to timestamped CSV files
  • CLI Interface: Easy-to-use command-line interface with Typer

Requirements

System Requirements

  • Android Debug Bridge (ADB): Version 1.0.40+
    • Install via: apt-get install android-tools-adb (Linux) or brew install android-platform-tools (macOS)
    • Verify installation: adb version
    • Ensure your Android device has USB debugging enabled
    • Device must be connected and appear in adb devices

Python Requirements

  • Python: 3.8 or higher
  • Dependencies:
    • typer>=0.9.0 - CLI framework

Installation

  1. Clone the repository:

    git clone https://git.truminds.co.in/truminds/performance-benchmarking/benchmarkingcli.git
    cd benchmarkingcli
    
  2. Install Python dependencies:

    pip install -r requirements.txt
    
  3. Verify ADB is installed and connected:

    adb devices
    

    You should see your connected device listed.

  4. Place the benchmark binary:

    • Copy the latency_test binary to the helper/ directory
    • The script will automatically push it to /data/local/tmp/ on the device

Usage

Latency Test

Run a basic latency benchmark on a specific core:

# Run on default core (7)
python main.py latency

# Run on a specific core
python main.py latency --core 4

This command will:

  1. Check for connected ADB devices
  2. Push the benchmark binary to the device
  3. Execute the latency test on the specified core
  4. Parse results and save to latency_results_<TIMESTAMP>.csv

Loaded Latency Test

Run a latency test with concurrent bandwidth load:

# Default — TRIAD kernel, core 7 for latency, cores 0-5 for bandwidth
python main.py loadedlatency \
  --lat-buffer-mb 128 \
  --bw-buffer-mb 128 \
  --latency-core 7 \
  --bw-cores 0,1,2,3,4,5 \
  --kernel-mode TRIAD

# SUM kernel (lightest — 1 array, read only)
python main.py loadedlatency \
  --lat-buffer-mb 128 \
  --bw-buffer-mb 128 \
  --latency-core 7 \
  --bw-cores 0,1,2,3,4,5 \
  --kernel-mode SUM

# COPY kernel (2 arrays — read + write)
python main.py loadedlatency \
  --lat-buffer-mb 128 \
  --bw-buffer-mb 128 \
  --latency-core 7 \
  --bw-cores 0,1,2,3 \
  --kernel-mode COPY

# UPDATE kernel (2 arrays — read + write with scalar multiply)
python main.py loadedlatency \
  --lat-buffer-mb 256 \
  --bw-buffer-mb 256 \
  --latency-core 7 \
  --bw-cores 0,1,2,3,4,5 \
  --kernel-mode UPDATE

# Numeric mode values also accepted (1=SUM, 2=COPY, 3=UPDATE, 4=TRIAD)
python main.py loadedlatency \
  --lat-buffer-mb 128 \
  --bw-buffer-mb 128 \
  --latency-core 7 \
  --bw-cores 0,1,2,3,4,5 \
  --kernel-mode 4

Parameters:

  • --lat-buffer-mb: Buffer size (MB) for the latency thread (default: 128)
  • --bw-buffer-mb: Buffer size (MB) for each bandwidth thread (default: 128)
  • --latency-core: CPU core to run the latency thread on (default: 7)
  • --bw-cores: Comma-separated list of cores for bandwidth threads (default: 0,1,2,3,4,5)
  • --kernel-mode: Bandwidth kernel to use — see table below (default: TRIAD)

Kernel Modes

Mode Value Arrays Description
SUM 1 1 Read-only sum — lightest BW pressure
COPY 2 2 Read + write — moderate BW pressure
UPDATE 3 2 Read + scalar write — moderate BW pressure
TRIAD 4 3 Read 2 + write 1 — heaviest BW pressure

Both the name (TRIAD) and numeric value (4) are accepted interchangeably.

Output

Results are exported as CSV files with the following columns:

  • buffer_size_kb: Size of the buffer tested (in KB)
  • min_ns: Minimum latency (nanoseconds)
  • mean_ns: Mean latency (nanoseconds)
  • max_ns: Maximum latency (nanoseconds)

Example output files:

  • latency_results_20260427_115540.csv
  • loaded_latency_results_20260427_115540.csv

Troubleshooting

"No ADB devices found"

  • Check that your Android device is connected: adb devices
  • Ensure USB debugging is enabled on the device
  • Try: adb kill-server then adb start-server

"Latency test binary not found"

  • Ensure the latency_test binary is placed in the helper/ directory
  • Verify the file exists: ls -la helper/latency_test

Binary push fails

  • Check device storage: adb shell df /data/local/tmp
  • Verify ADB permissions: adb shell ls -la /data/local/tmp

"Invalid kernel mode"

  • Use one of: SUM, COPY, UPDATE, TRIAD or their numeric equivalents 1, 2, 3, 4

Project Structure

benchmarkingcli/
├── main.py                              # CLI entry point
├── latency.py                           # Latency test runner
├── loaded_latency.py                    # Loaded latency test runner
├── parse_latency_result.py              # Result parsing and CSV export
├── requirements.txt                     # Python dependencies
├── helper/
│   ├── binary_helper.py                 # ADB and binary management
│   └── latency_test                     # Compiled benchmark binary
└── README.md                            # This file

Support

For issues, questions, or contributions, please contact the development team or submit an issue through the project repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

benchmarkingcli-0.0.2.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benchmarkingcli-0.0.2-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file benchmarkingcli-0.0.2.tar.gz.

File metadata

  • Download URL: benchmarkingcli-0.0.2.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for benchmarkingcli-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a9a90ea2f97c79d620bc41e8aa7b4f7bf46d93b7a14cdac103058bd87e7eeb11
MD5 448c04795fec6d85ab1826dba0c31acf
BLAKE2b-256 ed9e6d10434a03d7b57f1235fddb25c7b628d92be71254edf1883475f65599de

See more details on using hashes here.

File details

Details for the file benchmarkingcli-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for benchmarkingcli-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f792211a5c3b781c804f5ebf8b8750d7a7b6a7b699ca5cf3eeeccbfb7bb53e
MD5 846926bb82b9babaa1d713ba5b757c62
BLAKE2b-256 b98b344d7226d8368718052fdae945d5b2683853ab2bc81588cf025ffc580a7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page