Closed yuyang-ok closed 9 months ago
If I want pprof every 30s , just pprof current 30s cpu profiling. My code kind of like this.
let guard = pprof::ProfilerGuardBuilder::default() .frequency(1000) .blocklist(&["libc", "libgcc", "pthread", "vdso"]) .build() .unwrap(); loop { std::thread::sleep(Duration::from_secs(second)); let r = guard.report().build().unwrap(); let file = std::fs::File::create("/tmp/fabric_flamegraph.svg").unwrap(); let mut options = pprof::flamegraph::Options::default(); options.image_width = Some(2500); r.flamegraph_with_options(file, &mut options).unwrap(); println!("generated flamegraph"); }
should I put let guard in loop ?
let guard
Yes.
Profiling stopped when the guard is dropped, so putting it in the loop will stop the existing profiler before each iteration ends.
@YangKeao Thanks.
If I want pprof every 30s , just pprof current 30s cpu profiling. My code kind of like this.
should I put
let guard
in loop ?