pub struct WidthCosts { /* private fields */ }Expand description
Dispatch cost of one kind of token at the measured widths 2, 4 and 6.
The model: linear interpolation between the anchors, the value at width 2
below it, and above width 6 the width 6 value held flat (the Linux data at
width 8 is below the width 6 value, so flat is conservative and simple).
The model is evaluated once, when the value is built (new and flat are
const), into a table of nanoseconds, so a lookup is an index. Width 1 never
reaches the model: a token of one slot has no parallel section, see
Exec::dispatch_cost.
§Examples
use std::num::NonZeroUsize;
use std::time::Duration;
use threadteam::WidthCosts;
let us = Duration::from_micros;
let c = WidthCosts::new([us(3), us(2), us(1)]);
assert_eq!(c.at(NonZeroUsize::new(2).unwrap()), us(3));
assert_eq!(c.at(NonZeroUsize::new(3).unwrap()), Duration::from_nanos(2500));
assert_eq!(c.at(NonZeroUsize::new(12).unwrap()), us(1));
assert_eq!(c.min(), us(1));Implementations§
Source§impl WidthCosts
impl WidthCosts
Trait Implementations§
Source§impl Clone for WidthCosts
impl Clone for WidthCosts
impl Copy for WidthCosts
Source§impl Debug for WidthCosts
impl Debug for WidthCosts
impl Eq for WidthCosts
Source§impl PartialEq for WidthCosts
impl PartialEq for WidthCosts
impl StructuralPartialEq for WidthCosts
Auto Trait Implementations§
impl Freeze for WidthCosts
impl RefUnwindSafe for WidthCosts
impl Send for WidthCosts
impl Sync for WidthCosts
impl Unpin for WidthCosts
impl UnsafeUnpin for WidthCosts
impl UnwindSafe for WidthCosts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more