8 releases (4 breaking)
Uses old Rust 2015
0.6.0 | May 24, 2017 |
---|---|
0.5.0 | Apr 7, 2017 |
0.4.4 | Apr 3, 2017 |
0.4.3 | Mar 30, 2017 |
0.1.0 | Sep 27, 2016 |
#1566 in Filesystem
186 downloads per month
Used in 5 crates
(3 directly)
31KB
652 lines
Self-Meter
Status: | beta |
---|---|
Documentation: | https://docs.rs/self-meter/ |
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.
License
Licensed under either of
- Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
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));
}
}
Dependencies
~0.5–1.1MB
~26K SLoC