Skip to main content

BenchSample

Struct BenchSample 

Source
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: u64

Duration 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

Source§

fn clone(&self) -> BenchSample

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BenchSample

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BenchSample

Source§

fn default() -> BenchSample

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BenchSample

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<BenchSample> for BenchSampleFfi

Source§

fn from(sample: BenchSample) -> Self

Converts to this type from the input type.
Source§

impl From<BenchSample> for BenchSampleTemplate

Source§

fn from(sample: BenchSample) -> Self

Converts to this type from the input type.
Source§

impl From<BenchSampleFfi> for BenchSample

Source§

fn from(sample: BenchSampleFfi) -> Self

Converts to this type from the input type.
Source§

impl From<BenchSampleTemplate> for BenchSample

Source§

fn from(sample: BenchSampleTemplate) -> Self

Converts to this type from the input type.
Source§

impl Serialize for BenchSample

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> FromFfi<U> for T
where T: From<U>,

Source§

fn from_ffi(ffi: U) -> T

Convert from FFI representation to SDK type.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoFfi<U> for T
where U: From<T>,

Source§

fn into_ffi(self) -> U

Convert self into the FFI representation.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,