prock

Crates.ioprock
lib.rsprock
version0.2.8
created_at2026-01-08 19:32:33.403666+00
updated_at2026-01-24 19:02:21.929995+00
descriptionFast, low-overhead CPU statistics for process trees
homepage
repositoryhttps://github.com/paradigmxyz/mi6
max_upload_size
id2030935
size198,490
(sslivkoff)

documentation

README

prock

Fast, low-overhead CPU statistics for process trees.

Uses direct syscalls for minimal overhead (~1-5µs per process):

  • macOS: proc_pid_rusage via libproc
  • Linux: /proc/[pid]/stat filesystem reads

Features

  • CPU time (user + system) in nanoseconds
  • Memory usage (RSS and virtual)
  • Disk I/O statistics
  • Process tree discovery (parent/child relationships)
  • Tree-wide aggregation (sum stats across process + all descendants)

Usage

use 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 Support

Platform Status
macOS Full support via libproc
Linux Full support via /proc
Other Fallback (returns None)
Commit count: 0

cargo fmt