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
impl ProfilerBuilder
sourcepub fn testing(self) -> Self
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();
sourcepub fn file_name<P: AsRef<Path>>(self, file_name: P) -> Self
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();
sourcepub fn trim_backtraces(self, max_frames: Option<usize>) -> Self
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 byn
. Values ofn
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();