| Crates.io | prock |
| lib.rs | prock |
| version | 0.2.8 |
| created_at | 2026-01-08 19:32:33.403666+00 |
| updated_at | 2026-01-24 19:02:21.929995+00 |
| description | Fast, low-overhead CPU statistics for process trees |
| homepage | |
| repository | https://github.com/paradigmxyz/mi6 |
| max_upload_size | |
| id | 2030935 |
| size | 198,490 |
Fast, low-overhead CPU statistics for process trees.
Uses direct syscalls for minimal overhead (~1-5µs per process):
proc_pid_rusage via libproc/proc/[pid]/stat filesystem readsuse prock::{get_cpu_time, get_memory, get_all_stats};
// Get CPU time for a single process
if let Some(cpu) = get_cpu_time(pid) {
println!("CPU: {}ns user, {}ns system", cpu.user_ns, cpu.system_ns);
}
// Get memory for a single process
if let Some(mem) = get_memory(pid) {
println!("Memory: {} bytes", mem);
}
// Get all stats at once (more efficient for multiple metrics)
if let Some(stats) = get_all_stats(pid) {
println!("CPU: {:?}, Memory: {}", stats.cpu_time, stats.memory_bytes);
}
| Platform | Status |
|---|---|
| macOS | Full support via libproc |
| Linux | Full support via /proc |
| Other | Fallback (returns None) |