pub struct BenchSample {
pub duration_ns: u64,
pub cpu_time_ms: Option<u64>,
pub peak_memory_kb: Option<u64>,
pub process_peak_memory_kb: Option<u64>,
}Expand description
A single timing sample from a benchmark iteration.
Holds the elapsed wall time in nanoseconds plus optional per-iteration resource metrics (CPU time, peak memory growth, and process peak memory). The optional fields are only populated on platforms where the harness can capture them and are skipped from the JSON output when absent.
§Example
use mobench_sdk::timing::BenchSample;
let sample = BenchSample {
duration_ns: 1_500_000,
..Default::default()
};
// Convert to milliseconds
let ms = sample.duration_ns as f64 / 1_000_000.0;
assert_eq!(ms, 1.5);Fields§
§duration_ns: u64Duration of the iteration in nanoseconds.
Measured using std::time::Instant for monotonic, high-resolution timing.
cpu_time_ms: Option<u64>CPU time consumed by the measured iteration in milliseconds.
This is captured around the measured benchmark closure only and excludes warmup, setup, teardown, and report generation overhead.
peak_memory_kb: Option<u64>Peak memory growth during the measured iteration in kilobytes.
This legacy wire field is baseline-adjusted immediately before the measured closure enters. It reports growth during the measured iteration, not absolute process or device peak memory.
process_peak_memory_kb: Option<u64>Peak resident memory of the benchmark process during the measured iteration.
This is sampled from the current process while the measured closure is
running. Unlike peak_memory_kb, it is not baseline-adjusted.
Trait Implementations§
Source§impl Clone for BenchSample
impl Clone for BenchSample
Source§fn clone(&self) -> BenchSample
fn clone(&self) -> BenchSample
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more