pub struct Profiler { /* private fields */ }Expand description
A lightweight profiler that collects named timing events.
§Example
use shrew::profiler::Profiler;
let mut prof = Profiler::new();
let t = prof.start_event("forward", "compute");
// ... do work ...
prof.end_event(t, "forward", "compute");
let report = prof.report();
println!("{}", report);Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn start_event(&mut self, name: &str, _category: &str) -> Instant
pub fn start_event(&mut self, name: &str, _category: &str) -> Instant
Mark the start of a named event. Returns the Instant.
Sourcepub fn end_event(&mut self, start: Instant, name: &str, category: &str)
pub fn end_event(&mut self, start: Instant, name: &str, category: &str)
End an event started with [start_event]. Records elapsed time.
Sourcepub fn measure<F, R>(&mut self, name: &str, category: &str, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn measure<F, R>(&mut self, name: &str, category: &str, f: F) -> Rwhere
F: FnOnce() -> R,
Measure a closure and record it as a named event.
Sourcepub fn events(&self) -> &[ProfileEvent]
pub fn events(&self) -> &[ProfileEvent]
Return all recorded events.
Sourcepub fn total_time(&self) -> Duration
pub fn total_time(&self) -> Duration
Total wall-clock time across all events.
Sourcepub fn report(&self) -> ProfileReport
pub fn report(&self) -> ProfileReport
Generate a human-readable ProfileReport.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Profiler
impl RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnwindSafe for Profiler
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> 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