cathay4t/psm

★ 0Forks 0RustGitHub ↗Compare

README

psm

List the top CPU and memory consumers of the local machine, with the process names groomed for humans.

  • CPU is measured over a real sampling window. ps's %CPU column is cputime / elapsed-since-start, a lifetime average, so a process that was busy hours ago keeps showing ~100% long after it went idle. A QEMU process whose guest is sleeping is the classic case.
  • QEMU processes are shown as VM: <guest> instead of the (very long) qemu command line.
  • Browser child processes are folded into their application, so Firefox content processes show up as firefox instead of WebExtensions.
  • Names that mean nothing are aliased through a small lookup table, e.g. com.alibabainc.dingtalk shows up as dingtalk.
  • Electron apps are named after their --user-data-dir, so --user-data-dir=/home/fge/.config/qqmusic shows up as qqmusic.

Usage

psm [options]

  -n, --rows N           rows per table (default 10)
  -t, --sample SECONDS   CPU sampling window (default 1.0)
  -p, --per-process      show processes instead of grouping them by app
  -h, --help             show this help
  -V, --version          show the version

Example:

$ psm
=== top 10 by CPU over 1.0s (grouped by app) ===
    PID    CPU%      RSS  PROCESS
1062458   27.0%     7.8G  VM: ubt
  2746756    4.9%     1.5G  firefox (14 procs)
  3147427    1.0%    32.2G  VM: c4

=== top 10 by RSS (grouped by app) ===
    PID    CPU%      RSS  PROCESS
  3147427    1.0%    32.2G  VM: c4

Grouped memory is the sum of the resident sets of the group members, so pages shared between them are counted once per process.

Build

cargo build --release

Contributors

cathay4t

Issues