Struct specifications::profiling::ProfileReport
source · pub struct ProfileReport<W: Write> { /* private fields */ }
Expand description
Defines the toplevel ProfileReport that writes to stdout or disk or whatever when it goes out-of-scope.
Implementations§
source§impl ProfileReport<File>
impl ProfileReport<File>
sourcepub fn auto_reporting_file(
name: impl Into<String>,
file_name: impl Into<String>,
) -> Self
pub fn auto_reporting_file( name: impl Into<String>, file_name: impl Into<String>, ) -> Self
Constructor for the ProfileReport that will write it to a file in a default location (/logs/profile
) with a default name (date & time of the profile state) when it goes out-of-scope.
§Arguments
name
: The name for the toplevel scope in this report.filename
: A more snake-case-like filename for the file.
§Returns
A new ProfileReport instance.
source§impl<W: Write> ProfileReport<W>
impl<W: Write> ProfileReport<W>
sourcepub fn auto_reporting(name: impl Into<String>, writer: impl Into<W>) -> Self
pub fn auto_reporting(name: impl Into<String>, writer: impl Into<W>) -> Self
sourcepub fn scope(&self) -> &ProfileScope
pub fn scope(&self) -> &ProfileScope
Returns the inner scope that can be used without worrying about auto-reporting.
§Returns
A reference to the ProfileScope
that can be used to do anything except the gnarly auto-reporting.
sourcepub fn into_scope(self) -> ProfileScope
pub fn into_scope(self) -> ProfileScope
Returns the inner scope that can be used without worrying about auto-reporting.
§Returns
A ProfileScope
that can be used to do anything except the gnarly auto-reporting.
Methods from Deref<Target = ProfileScope>§
sourcepub fn time(&self, name: impl Into<String>) -> TimerGuard<'_>
pub fn time(&self, name: impl Into<String>) -> TimerGuard<'_>
sourcepub fn time_fut<'s, R>(
&'s self,
name: impl Into<String>,
fut: impl 's + Future<Output = R>,
) -> impl 's + Future<Output = R>
pub fn time_fut<'s, R>( &'s self, name: impl Into<String>, fut: impl 's + Future<Output = R>, ) -> impl 's + Future<Output = R>
sourcepub fn nest(&self, name: impl Into<String>) -> ProfileScopeHandle<'_>
pub fn nest(&self, name: impl Into<String>) -> ProfileScopeHandle<'_>
sourcepub fn nest_func<R>(
&self,
name: impl Into<String>,
func: impl FnOnce(ProfileScopeHandle<'_>) -> R,
) -> R
pub fn nest_func<R>( &self, name: impl Into<String>, func: impl FnOnce(ProfileScopeHandle<'_>) -> R, ) -> R
Profiles the given function, but provides it with extra profile options by giving it its own ProfileScope to populate.
Note that the ProfileScope is already automatically given a “total”-timing, representing the function’s profiling. This is still untimed as long as the function sees it, obviously.
§Arguments
name
: The name to set for this Timing.func
: The function to profile.
§Returns
The result of the function, if any.
sourcepub fn nest_fut<'s, F: Future>(
&'s self,
name: impl Into<String>,
fut: impl 's + FnOnce(ProfileScopeHandle<'s>) -> F,
) -> impl 's + Future<Output = F::Output>
pub fn nest_fut<'s, F: Future>( &'s self, name: impl Into<String>, fut: impl 's + FnOnce(ProfileScopeHandle<'s>) -> F, ) -> impl 's + Future<Output = F::Output>
Profiles the given future by creating a future that times it while running, but provides it with extra profile options by giving it its own ProfileScope to popupate.
Note that the ProfileScope is already automatically given a “total”-timing, representing the future’s profiling. This is still untimed as long as the future sees it, obviously.
§Arguments
name
: The name to set for this Timing.fut
: The Future to profile.
§Returns
A future that returns the same result as the given, but times its execution as a side-effect.
sourcepub fn display(&self) -> ProfileScopeFormatter<'_>
pub fn display(&self) -> ProfileScopeFormatter<'_>
Returns a formatter that neatly displays the results of this scope.
Note that this does not end with a newline, so typically you want to call writeln!()
/println!()
on this.
§Returns
A new ProfileScopeFormatter.
sourcepub fn display_indented(&self, indent: usize) -> ProfileScopeFormatter<'_>
pub fn display_indented(&self, indent: usize) -> ProfileScopeFormatter<'_>
Returns a formatter that neatly displays the results of this scope with a given number of spaces before each line.
Note that this does not end with a newline, so typically you want to call writeln!()
/println!()
on this.
§Arguments
indent
: The number of spaces to print before each line.
§Returns
A new ProfileScopeFormatter.
Trait Implementations§
source§impl<W: Write> Deref for ProfileReport<W>
impl<W: Write> Deref for ProfileReport<W>
source§impl<'de, W> Deserialize<'de> for ProfileReport<W>where
W: Deserialize<'de> + Write,
impl<'de, W> Deserialize<'de> for ProfileReport<W>where
W: Deserialize<'de> + Write,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<W: Write> Drop for ProfileReport<W>
impl<W: Write> Drop for ProfileReport<W>
Auto Trait Implementations§
impl<W> !Freeze for ProfileReport<W>
impl<W> !RefUnwindSafe for ProfileReport<W>
impl<W> Send for ProfileReport<W>where
W: Send,
impl<W> Sync for ProfileReport<W>where
W: Sync,
impl<W> Unpin for ProfileReport<W>where
W: Unpin,
impl<W> !UnwindSafe for ProfileReport<W>
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request