Crate mobench_runner

Crate mobench_runner 

Source
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

TypeDescription
BenchSpecBenchmark configuration (name, iterations, warmup)
BenchSampleSingle timing measurement in nanoseconds
BenchReportComplete results with all samples
BenchErrorError conditions during benchmarking

§Crate Ecosystem

This crate is part of the mobench ecosystem:

Structs§

BenchReport
Complete benchmark report with all timing samples.
BenchSample
A single timing sample from a benchmark iteration.
BenchSpec
Benchmark specification defining what and how to benchmark.

Enums§

BenchError
Errors that can occur during benchmark execution.

Functions§

run_closure
Runs a benchmark by executing a closure repeatedly.