pub fn io() -> Result<ProcessIo>Expand description
How much this process has read from and written to storage, for a
database’s own write amplification or a backup tool’s throughput. Two
readings subtract; Rate::per turns the difference
into a rate.
use std::time::Duration;
use sys_lib::{self as sys, Rate};
match sys::process::io() {
Ok(before) => {
// ... work ...
let d = sys::process::io()? - before;
println!("wrote {} ({})", d.written, Rate::per(d.written, Duration::from_secs(1)));
}
// FreeBSD and iOS do not count this process's bytes.
Err(e) if e.is_unavailable() => {}
Err(e) => return Err(e),
}§Errors
NotFound or PermissionDenied when /proc/self/io is hidden;
Unsupported on FreeBSD (it counts block operations, not bytes) and iOS;
Os.