pub struct Profiler { /* private fields */ }Expand description
Accumulates wall-clock measurements for repeated operations.
Typical use:
ⓘ
let mut p = Profiler::new("open");
p.start();
// ... do work ...
p.stop();
println!("{}", p.report());Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start a timing lap.
Calling start when a lap is already running resets the start time.
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stop the current timing lap and record the measurement.
If start was never called, this is a no-op.
Sourcepub fn report(&self) -> String
pub fn report(&self) -> String
Returns a human-readable statistics table.
Columns: count | min ms | mean ms | median ms | p95 ms | p99 ms | max ms
Sourcepub fn export_json(&self) -> Result<String>
pub fn export_json(&self) -> Result<String>
Serialise the statistics + raw measurements to a pretty-printed JSON string.
§Errors
Returns an error if JSON serialisation fails (should not happen in practice).
Auto Trait Implementations§
impl Freeze for Profiler
impl RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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