pub struct SystemSampler { /* private fields */ }Available on crate feature
system-stats only.Expand description
Stateful sampler that refreshes process info on demand.
Allocates one sysinfo::System instance for reuse across samples.
§Example (ignored: requires sysinfo + a real process)
ⓘ
use dev_stress::system::SystemSampler;
let mut sampler = SystemSampler::new();
let before = sampler.sample().unwrap();
// ... run workload ...
let after = sampler.sample().unwrap();
assert!(after.rss_bytes >= before.rss_bytes.saturating_sub(1024 * 1024));Implementations§
Source§impl SystemSampler
impl SystemSampler
Sourcepub fn sample(&mut self) -> Option<SystemStats>
pub fn sample(&mut self) -> Option<SystemStats>
Capture a SystemStats snapshot.
Returns None if the OS has no record of the process (extremely
rare; would imply the current PID is unknown).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SystemSampler
impl RefUnwindSafe for SystemSampler
impl Send for SystemSampler
impl Sync for SystemSampler
impl Unpin for SystemSampler
impl UnsafeUnpin for SystemSampler
impl UnwindSafe for SystemSampler
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