Skip to main content

AcquisitionStream

Struct AcquisitionStream 

Source
pub struct AcquisitionStream { /* private fields */ }
Expand description

An interleaved acquisition stream of timing measurements.

Measurement produces an interleaved stream indexed by acquisition time: {(c_t, y_t)} where c_t is the class label and y_t is the timing.

This structure is critical for correct dependence estimation. The underlying stochastic process operates in continuous time—drift, frequency scaling, and cache state evolution affect nearby samples regardless of class. Bootstrap resampling must preserve adjacency in acquisition order, not per-class position.

See spec Section 2.3.1 for the full rationale.

Implementations§

Source§

impl AcquisitionStream

Source

pub fn new() -> Self

Create a new empty acquisition stream.

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new acquisition stream with pre-allocated capacity.

Source

pub fn push(&mut self, class: SampleClass, timing: f64)

Push a new sample onto the stream.

Source

pub fn push_batch_interleaved(&mut self, fixed: &[f64], random: &[f64])

Push a batch of samples, interleaving Fixed and Random classes.

Samples are pushed in interleaved order: F, R, F, R, … Both vectors must have the same length.

Source

pub fn len(&self) -> usize

Get the total number of samples in the stream.

Source

pub fn is_empty(&self) -> bool

Check if the stream is empty.

Source

pub fn n_per_class(&self) -> usize

Get the number of samples per class (assumes balanced classes).

Source

pub fn split_by_class(&self) -> (Vec<f64>, Vec<f64>)

Split the stream into per-class vectors.

Returns (fixed_timings, random_timings).

Source

pub fn timings(&self) -> impl Iterator<Item = f64> + '_

Get an iterator over all timings (ignoring class labels).

Used for ACF computation on the pooled stream.

Source

pub fn as_slice(&self) -> &[(SampleClass, f64)]

Get a slice of the raw samples.

Source

pub fn as_mut_slice(&mut self) -> &mut [(SampleClass, f64)]

Get mutable access to the raw samples.

Source

pub fn iter(&self) -> impl Iterator<Item = &(SampleClass, f64)>

Get an iterator over (class, timing) pairs.

Source

pub fn clear(&mut self)

Clear the stream, removing all samples but keeping capacity.

Source

pub fn truncate(&mut self, len: usize)

Truncate the stream to the given length.

Source

pub fn get(&self, index: usize) -> Option<&(SampleClass, f64)>

Get the sample at the given index.

Source

pub fn from_raw_interleaved( baseline: &[u64], sample: &[u64], ns_per_tick: f64, ) -> Self

Convert raw u64 measurements to nanoseconds and store as stream.

Interleaves the measurements: baseline[0], sample[0], baseline[1], sample[1], ...

Source

pub fn to_timing_samples(&self) -> Vec<TimingSample>

Convert to Vec<TimingSample> for bootstrap functions.

This is an adapter method that converts the acquisition stream to the TimingSample format used by the bootstrap covariance estimation functions.

Maps SampleClass::FixedClass::Baseline, SampleClass::RandomClass::Sample.

Trait Implementations§

Source§

impl Clone for AcquisitionStream

Source§

fn clone(&self) -> AcquisitionStream

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 AcquisitionStream

Source§

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

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

impl Default for AcquisitionStream

Source§

fn default() -> AcquisitionStream

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

impl<'de> Deserialize<'de> for AcquisitionStream

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 Serialize for AcquisitionStream

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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>,