systrack

Crates.iosystrack
lib.rssystrack
version0.1.0
sourcesrc
created_at2023-10-07 01:17:03.990449
updated_at2023-10-07 01:17:03.990449
descriptionTrack system resource usage over custom lapses
homepage
repositoryhttps://github.com/jdvillal/systrack
max_upload_size
id995937
size20,935
Jorge Villalta (jdvillal)

documentation

README

systrack

Track system resource usage over custom lapses.

Usage examples

Create a tracker that records CPU usage.

let mut cpu_tracker = SystemTracker::new_cpu_tracker();

This creates a structure that keep track of CPU usage over the last minute (by default). Interally, a background thread updates the historical information twice per second.

If you want a tracker to save historical data for a longer lapse, you should create the tracker using new_cpu_tracker_with_capacity().

To get the historical data, you can call fetch_usage().

for _ in 0..10 {
  println!("{:?}", cpu_tracker.fetch_usage());
  thread::sleep(Duration::from_millis(500));
}

Also, if you want the tracker to stop recording, you can call stop().

cpu_tracker.stop();
for _ in 0..5 {
  println!("{:?}", cpu_tracker.fetch_usage());
  thread::sleep(Duration::from_millis(500));
}

Keep in mind that once the stop() method is called, the fetch_usage() method will always return None.

Memory usage tracker works almost identical. Check the examples dir for more.

Commit count: 9

cargo fmt