Struct dhat::ProfilerBuilder[][src]

pub struct ProfilerBuilder { /* fields omitted */ }
Expand description

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

Created with Profiler::builder.

Implementations

Requests ad hoc profiling.

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

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();

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();

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();

Creates a Profiler from the builder and initiates profiling.

Panics

Panics if another Profiler is running.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.