pub struct ProfilerRunner { /* private fields */ }Expand description
A background thread that dumps out stats, flamegraphs, and does other periodic cleanup.
- Dumps out top retained memory stats to both logs and disk
- Can optionally dump out flamegraphs
- Lets you choose between dumping retained or allocated reports/flamegraphs
The runner thread will check the amount of retained memory as estimated by this profiler,
every check_interval_secs. If the retained memory changes from the previous time by more than
report_pct_change_trigger, then it will dump out a memory report of the top either retained
or allocated stack traces as a file to the chosen reporting_path directory on disk. The file will
have the ISO8601 timestamp and the amount of retained memory in the filename for convenience.
Optionally, a flamegraph will also be dumped.
Note that ProfilerRunner uses log framework to periodically dump out logs. The app is responsible for initializing the logging infrastructure.
To run. no_run because spawning the reporting thread and creating its output directory are
side effects that do not belong in a doctest:
use ying_profiler::{YingProfiler, utils::ProfilerRunner};
static YING_ALLOC: YingProfiler = YingProfiler::default();
ProfilerRunner::default().spawn(&YING_ALLOC);Builder pattern can also be used.
use ying_profiler::{YingProfiler, utils::ProfilerRunnerBuilder};
static YING_ALLOC: YingProfiler = YingProfiler::default();
let runner = ProfilerRunnerBuilder::default()
.check_interval_secs(60usize)
.gen_flamegraphs(true)
.reporting_path("profiler_output/")
.build()
.unwrap();
runner.spawn(&YING_ALLOC);Implementations§
Source§impl ProfilerRunner
impl ProfilerRunner
Sourcepub fn new(
check_interval_secs: usize,
report_pct_change_trigger: usize,
reporting_path: &str,
expand_frames: bool,
gen_flamegraphs: bool,
measure_allocated_not_retained: bool,
) -> Self
pub fn new( check_interval_secs: usize, report_pct_change_trigger: usize, reporting_path: &str, expand_frames: bool, gen_flamegraphs: bool, measure_allocated_not_retained: bool, ) -> Self
Creates a new ProfilerRunner with specific parameters
Sourcepub fn spawn(&self, profiler: &'static YingProfiler)
pub fn spawn(&self, profiler: &'static YingProfiler)
Spawn a new background thread to run profiler and get stats.
Creates reporting_path if it does not already exist.
Trait Implementations§
Source§impl Clone for ProfilerRunner
impl Clone for ProfilerRunner
Source§fn clone(&self) -> ProfilerRunner
fn clone(&self) -> ProfilerRunner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProfilerRunner
impl Debug for ProfilerRunner
Source§impl Default for ProfilerRunner
Creates a new ProfilerRunner with default values. Writes reports to current directory, does not expand frames,
every 5 minute checks on memory, 10% change triggers report. No flamegraphs, retained memory.
impl Default for ProfilerRunner
Creates a new ProfilerRunner with default values. Writes reports to current directory, does not expand frames, every 5 minute checks on memory, 10% change triggers report. No flamegraphs, retained memory.