Struct dhat::ProfilerBuilder

source ·
pub struct ProfilerBuilder { /* private fields */ }
Expand description

A builder for Profiler, for cases beyond the basic ones provided by Profiler.

Created with Profiler::builder.

Implementations§

source§

impl ProfilerBuilder

source

pub fn ad_hoc(self) -> Self

Requests ad hoc profiling.

§Examples
let _profiler = dhat::Profiler::builder().ad_hoc().build();
source

pub fn testing(self) -> Self

Requests testing mode, which allows the use of dhat::assert! and related macros, and disables saving of profile data on Profiler drop.

§Examples
let _profiler = dhat::Profiler::builder().testing().build();
source

pub fn file_name<P: AsRef<Path>>(self, file_name: P) -> Self

Sets the name of the file in which profiling data will be saved.

§Examples
let file_name = format!("heap-{}.json", std::process::id());
let _profiler = dhat::Profiler::builder().file_name(file_name).build();
source

pub fn trim_backtraces(self, max_frames: Option<usize>) -> Self

Sets how backtrace trimming is performed.

dhat can use heuristics to trim uninteresting frames from the top and bottom of backtraces, which makes the output easier to read. It can also limit the number of frames, which improves performance.

The argument can be specified in several ways.

  • None: no backtrace trimming will be performed, and there is no frame count limit. This makes profiling much slower and increases the size of saved data files.
  • Some(n): top and bottom trimming will be performed, and the number of frames will be limited by n. Values of n less than 4 will be clamped to 4.
  • Some(usize::MAX): top and bottom trimming with be performed, but there is no frame count limit. This makes profiling much slower and increases the size of saved data files.

The default value (used if this function is not called) is Some(10).

The number of frames shown in viewed profiles may differ from the number requested here, for two reasons.

  • Inline frames do not count towards this length. In release builds it is common for the number of inline frames to equal or even exceed the number of “real” frames.
  • Backtrace trimming will remove a small number of frames from heap profile backtraces. The number removed will likely be more in a debug build than in a release build.
§Examples
let _profiler = dhat::Profiler::builder().trim_backtraces(None).build();
source

pub fn build(self) -> Profiler

Creates a Profiler from the builder and initiates profiling.

§Panics

Panics if another Profiler is running.

Trait Implementations§

source§

impl Debug for ProfilerBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.