Expand description
§mobench
Command-line tool for building and running Rust benchmarks on mobile devices.
§Overview
mobench is the CLI orchestrator for the mobench ecosystem. It handles:
- Building - Compiles Rust code for Android/iOS and packages mobile apps
- Running - Executes benchmarks locally or on BrowserStack devices
- Reporting - Collects and formats benchmark results
§Installation
cargo install mobench§Quick Start
# Initialize a benchmark project
cargo mobench init --target android --output bench-config.toml
# Build for Android
cargo mobench build --target android
# Build for iOS
cargo mobench build --target ios
# Run locally (no device required)
cargo mobench run --target android --function my_benchmark --local-only
# Run on BrowserStack (use --release for smaller APK uploads)
cargo mobench run --target android --function my_benchmark \
--iterations 100 --warmup 10 --devices "Google Pixel 7-13.0" --release§Commands
| Command | Description |
|---|---|
init | Initialize a new benchmark project |
build | Build mobile artifacts (APK/xcframework) |
run | Execute benchmarks locally or on devices |
ci run | Run standardized CI orchestration (summary.json, summary.md, results.csv) |
doctor | Validate local/CI prerequisites and configuration |
config validate | Validate run config + matrix contract |
devices resolve | Resolve deterministic device sets from matrix/profile |
fixture ... | Fixture lifecycle helpers (init, build, verify, cache-key) |
report ... | Render markdown and publish sticky PR comments |
list | List discovered benchmark functions |
fetch | Retrieve results from BrowserStack |
package-ipa | Package iOS app as IPA |
package-xcuitest | Package XCUITest runner |
§Output Directory
All build artifacts are written to target/mobench/ by default:
target/mobench/
├── android/ # Android project and APK
└── ios/ # iOS project, xcframework, and IPAUse --output-dir to customize the output location.
§Configuration
Benchmarks can be configured via command-line arguments or a TOML config file:
target = "android"
function = "my_crate::my_benchmark"
iterations = 100
warmup = 10
[browserstack]
app_automate_username = "${BROWSERSTACK_USERNAME}"
app_automate_access_key = "${BROWSERSTACK_ACCESS_KEY}"
project = "my-project"§BrowserStack Integration
The CLI integrates with BrowserStack App Automate for running benchmarks on real devices. Set credentials via environment variables:
export BROWSERSTACK_USERNAME="your_username"
export BROWSERSTACK_ACCESS_KEY="your_access_key"§Crate Ecosystem
This crate is part of the mobench ecosystem:
mobench(this crate) - CLI toolmobench-sdk- Core SDK with timing harness and build automationmobench-macros-#[benchmark]proc macro
Note: The mobench-runner crate has been consolidated into mobench-sdk as its timing module.
§CLI Flags
Global flags available on all commands:
--dry-run- Preview what would be done without making changes--verbose/-v- Enable detailed output showing all commands
§Modules
config- Configuration file support formobench.toml
Modules§
Structs§
- Device
Selection - Device input sources used by
RunRequest. - Extracted
Benchmark Result - Extracted benchmark result for a single device.
- Report
- Standardized output file locations produced by a run.
- RunRequest
- Programmatic request payload for running a mobench benchmark flow.
- RunResult
- Result of a programmatic mobench run request.
Enums§
- Mobile
Target - Mobile platform target for build/run operations.
Functions§
- extract_
benchmark_ summary - Extract a unified summary from per-device benchmark results.
- run
- run_
request - Executes a
RunRequestby invoking the currentmobenchbinary and normalizing outputs.