Skip to main content

ResourceEstimate

Struct ResourceEstimate 

Source
#[non_exhaustive]
pub struct ResourceEstimate { /* private fields */ }
Expand description

Predicted resources for an encode (or decode) operation.

Every field is Option — a codec fills in what it models and leaves the rest None (the trait default is ResourceEstimate::unknown, all-None). When a ThreadingInformation is carried, ResourceEstimate::at_cores re-scales wall_ms for a given core count (leaving cpu_ms and peak unchanged). Compare against ResourceLimits to decide whether to admit a job.

Sealed and growable: build via new / unknown + the with_* setters, read with the accessors.

Implementations§

Source§

impl ResourceEstimate

Source

pub fn unknown() -> Self

An empty estimate — every field None. This is what a codec that does not model its resource use returns (and the trait default); codecs that do model fill in what they can with the with_* setters. Read fields back as Option.

Source

pub fn new(peak_memory_bytes_est: u64, wall_ms: u64) -> Self

An estimate from the two essentials: the typical (estimated) peak memory and the wall time. Everything else — peak_memory_bytes_max, cpu_ms, and threading — is left None; refine with the with_* setters. With no threading, at_cores is a no-op until you add one.

Source

pub fn with_peak_max(self, max: u64) -> Self

Set the conservative upper-bound peak memory (bytes).

Source

pub fn with_cpu_ms(self, cpu_ms: u64) -> Self

Set the total CPU-time estimate in milliseconds (work summed across all threads). Unlike wall_ms, it is not divided down by core count.

Source

pub fn with_threading(self, threading: ThreadingInformation) -> Self

Attach the operation’s core-scaling model.

Source

pub fn peak_memory_bytes_est(&self) -> Option<u64>

Typical (≈ p50) estimated peak memory for natural content, bytes.

Source

pub fn peak_memory_bytes_max(&self) -> Option<u64>

Conservative upper-bound peak memory (worst content + margin), bytes.

Source

pub fn wall_ms(&self) -> Option<u64>

Predicted wall-clock time in milliseconds (single-thread unless produced by at_cores).

Source

pub fn cpu_ms(&self) -> Option<u64>

Predicted total CPU time in milliseconds (work summed across all threads). Unaffected by at_cores.

Source

pub fn threading(&self) -> Option<ThreadingInformation>

How the operation scales across cores.

Source

pub fn at_cores(&self, cores: usize) -> Self

Re-scale the predicted wall time for cores available CPU cores using the carried ThreadingInformation: wall_ms is divided by the effective thread count — linear speedup up to max_efficient_threads, the knee of the scaling curve. self must carry the single-thread time. Peak memory and CPU time are unchanged. A None wall_ms or None threading is returned unscaled.

Source

pub fn conservative(image: &ImageCharacteristics) -> Self

A conservative, content- and codec-blind fallback for operations without a calibrated model: peak ≈ input buffer + a generous working multiple, serial. Real codecs override EncoderConfig::estimate_encode_resources with their heuristics model.

Trait Implementations§

Source§

impl Clone for ResourceEstimate

Source§

fn clone(&self) -> ResourceEstimate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ResourceEstimate

Source§

impl Debug for ResourceEstimate

Source§

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

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

impl PartialEq for ResourceEstimate

Source§

fn eq(&self, other: &ResourceEstimate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResourceEstimate

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> 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.