Crate self_meter [−] [src]
A tiny library to measure resource usage of the process it's used in. Currently it measures:
- Memory Usage
- CPU Usage with breakdown by each thread
- Disk Usage
More metrics might be added later. Currently, library supports only linux, but pull requests for other platforms are welcome.
Example
fn main() { let mut meter = self_meter::Meter::new(Duration::new(1, 0)).unwrap(); meter.track_current_thread("main"); loop { meter.scan() .map_err(|e| writeln!(&mut stderr(), "Scan error: {}", e)).ok(); println!("Report: {:#?}", meter.report()); println!("Threads: {:#?}", meter.thread_report().map(|x| x.collect::<BTreeMap<_,_>>())); // Put your task here // ... // sleep(Duration::new(1, 0)); } }
Structs
Meter |
The main structure that makes mesurements and reports values |
Report |
Report returned by |
ThreadReport |
Report of CPU usage by single thread |
ThreadReportIter |
Iterator over thread reports returned by |
ThreadUsage |
CPU usage of a single thread |
Enums
Error |
Error scanning process info in /proc |
Type Definitions
Pid |
A Pid type used to identify processes and threads |