Expand description
Mobile Benchmark SDK for Rust
bench-sdk is a library for benchmarking Rust functions on real mobile devices
(Android and iOS) via BrowserStack. It provides a simple API similar to criterion.rs
but targets mobile platforms.
§Quick Start
- Add bench-sdk to your project:
[dependencies]
bench-sdk = "0.1"- Mark functions with
#[benchmark]:
ⓘ
use mobench_sdk::benchmark;
#[benchmark]
fn my_expensive_operation() {
// Your code here
let result = compute_something();
std::hint::black_box(result);
}- Initialize mobile project:
cargo bench-sdk init --target android- Build and run:
cargo bench-sdk build --target android
cargo bench-sdk run my_expensive_operation --target android§Architecture
The SDK consists of several components:
- Registry: Discovers functions marked with
#[benchmark]at runtime - Runner: Executes benchmarks and collects timing data
- Builders: Automates building Android/iOS apps
- Codegen: Generates mobile app templates
§Example: Programmatic Usage
ⓘ
use mobench_sdk::{BenchmarkBuilder, BenchSpec};
fn main() -> Result<(), mobench_sdk::BenchError> {
// Using the builder pattern
let report = BenchmarkBuilder::new("my_benchmark")
.iterations(100)
.warmup(10)
.run()?;
println!("Samples: {}", report.samples.len());
// Or using BenchSpec directly
let spec = BenchSpec {
name: "my_benchmark".to_string(),
iterations: 50,
warmup: 5,
};
let report = mobench_sdk::run_benchmark(spec)?;
Ok(())
}Re-exports§
pub use registry::BenchFunction;pub use registry::discover_benchmarks;pub use registry::find_benchmark;pub use registry::list_benchmark_names;pub use runner::BenchmarkBuilder;pub use runner::run_benchmark;pub use types::BenchError;pub use types::BuildConfig;pub use types::BuildProfile;pub use types::BuildResult;pub use types::InitConfig;pub use types::Target;pub use mobench_runner;
Modules§
- builders
- Build automation for mobile platforms
- codegen
- Code generation and template management
- registry
- Benchmark function registry
- runner
- Benchmark execution runtime
- types
- Core types for bench-sdk
Structs§
Constants§
- VERSION
- Library version
Attribute Macros§
- benchmark
- Marks a function as a benchmark.