pub struct Cpu(/* private fields */);
Available on Unix only.
Expand description
A CPU profiler.
Call Cpu::capture
to capture a pprof profile for the given duration.
Implementations§
Source§impl Cpu
impl Cpu
Sourcepub fn new<S: AsRef<str>>(frequency: i32, blocklist: &[S]) -> Self
pub fn new<S: AsRef<str>>(frequency: i32, blocklist: &[S]) -> Self
Create a new CPU profiler.
frequency
is the sampling frequency in Hz.blocklist
is a list of functions to exclude from the profile.
Sourcepub fn capture(&self, duration: Duration) -> Result<Vec<u8>, PprofError>
pub fn capture(&self, duration: Duration) -> Result<Vec<u8>, PprofError>
Capture a pprof profile for the given duration.
The profile is compressed using gzip.
The profile can be analyzed using the pprof
tool.
Warning: This method is blocking and may take a long time to complete.
It is recommended to run it in a separate thread.
Auto Trait Implementations§
impl Freeze for Cpu
impl RefUnwindSafe for Cpu
impl Send for Cpu
impl Sync for Cpu
impl Unpin for Cpu
impl UnwindSafe for Cpu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more