pub struct Token<C: Clock = SystemClock> { /* private fields */ }Expand description
An in progress COGS measurement.
The measurement is recorded when the token is dropped.
Implementations§
Source§impl<C: Clock> Token<C>
impl<C: Clock> Token<C>
Sourcepub fn noop() -> Selfwhere
C: Default,
pub fn noop() -> Selfwhere
C: Default,
Creates a new no-op token, which records nothing.
This is primarily useful for testing.
Sourcepub fn start_category(
&mut self,
category: impl Category,
) -> CategoryToken<'_, C>
pub fn start_category( &mut self, category: impl Category, ) -> CategoryToken<'_, C>
Starts a categorized measurement.
The measurement is finalized when the returned CategoryToken is dropped.
Instead of manually starting a categorized measurement, the crate::with
macro can be used.
Sourcepub fn update<T: Into<FeatureWeights>>(&mut self, features: T)
pub fn update<T: Into<FeatureWeights>>(&mut self, features: T)
Updates the app features to which the active measurement is attributed to.
§Example:
fn process(cogs: &Cogs, item: &Item) {
let mut token = cogs.timed(ResourceId::Relay, AppFeature::Unattributed);
// App feature is only known after some computations.
if do_something(item) {
token.update(AppFeature::Spans);
} else {
token.update(AppFeature::Transactions);
}
}Trait Implementations§
Auto Trait Implementations§
impl<C = SystemClock> !RefUnwindSafe for Token<C>
impl<C = SystemClock> !UnwindSafe for Token<C>
impl<C> Freeze for Token<C>where
C: Freeze,
impl<C> Send for Token<C>where
C: Send,
impl<C> Sync for Token<C>where
C: Sync,
impl<C> Unpin for Token<C>where
C: Unpin,
impl<C> UnsafeUnpin for Token<C>where
C: UnsafeUnpin,
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