#[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
impl ResourceEstimate
Sourcepub fn unknown() -> Self
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.
Sourcepub fn new(peak_memory_bytes_est: u64, wall_ms: u64) -> Self
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.
Sourcepub fn with_peak_max(self, max: u64) -> Self
pub fn with_peak_max(self, max: u64) -> Self
Set the conservative upper-bound peak memory (bytes).
Sourcepub fn with_cpu_ms(self, cpu_ms: u64) -> Self
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.
Sourcepub fn with_threading(self, threading: ThreadingInformation) -> Self
pub fn with_threading(self, threading: ThreadingInformation) -> Self
Attach the operation’s core-scaling model.
Sourcepub fn peak_memory_bytes_est(&self) -> Option<u64>
pub fn peak_memory_bytes_est(&self) -> Option<u64>
Typical (≈ p50) estimated peak memory for natural content, bytes.
Sourcepub fn peak_memory_bytes_max(&self) -> Option<u64>
pub fn peak_memory_bytes_max(&self) -> Option<u64>
Conservative upper-bound peak memory (worst content + margin), bytes.
Sourcepub fn wall_ms(&self) -> Option<u64>
pub fn wall_ms(&self) -> Option<u64>
Predicted wall-clock time in milliseconds (single-thread unless
produced by at_cores).
Sourcepub fn cpu_ms(&self) -> Option<u64>
pub fn cpu_ms(&self) -> Option<u64>
Predicted total CPU time in milliseconds (work summed across all
threads). Unaffected by at_cores.
Sourcepub fn threading(&self) -> Option<ThreadingInformation>
pub fn threading(&self) -> Option<ThreadingInformation>
How the operation scales across cores.
Sourcepub fn at_cores(&self, cores: usize) -> Self
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.
Sourcepub fn conservative(image: &ImageCharacteristics) -> Self
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
impl Clone for ResourceEstimate
Source§fn clone(&self) -> ResourceEstimate
fn clone(&self) -> ResourceEstimate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more