Expand description
§mobench-runner
A lightweight benchmarking harness designed for mobile platforms.
This crate provides the core timing infrastructure for the mobench ecosystem. It’s designed to be minimal and portable, with no platform-specific dependencies, making it suitable for compilation to Android and iOS targets.
§Overview
The runner executes benchmark functions with:
- Configurable warmup iterations
- Precise nanosecond-resolution timing
- Simple, serializable results
§Usage
Most users should use this crate via mobench-sdk.
Direct usage is typically only needed for custom integrations:
use mobench_runner::{BenchSpec, run_closure, BenchError};
// Define a benchmark specification
let spec = BenchSpec::new("my_benchmark", 100, 10)?;
// Run the benchmark
let report = run_closure(spec, || {
// Your benchmark code
let sum: u64 = (0..1000).sum();
std::hint::black_box(sum);
Ok(())
})?;
// Analyze results
let mean_ns = report.samples.iter()
.map(|s| s.duration_ns)
.sum::<u64>() / report.samples.len() as u64;
println!("Mean: {} ns", mean_ns);§Types
| Type | Description |
|---|---|
BenchSpec | Benchmark configuration (name, iterations, warmup) |
BenchSample | Single timing measurement in nanoseconds |
BenchReport | Complete results with all samples |
BenchError | Error conditions during benchmarking |
§Crate Ecosystem
This crate is part of the mobench ecosystem:
mobench-sdk- Core SDK with build automationmobench- CLI toolmobench-macros-#[benchmark]proc macromobench-runner(this crate) - Timing harness
Structs§
- Bench
Report - Complete benchmark report with all timing samples.
- Bench
Sample - A single timing sample from a benchmark iteration.
- Bench
Spec - Benchmark specification defining what and how to benchmark.
Enums§
- Bench
Error - Errors that can occur during benchmark execution.
Functions§
- run_
closure - Runs a benchmark by executing a closure repeatedly.