#!/usr/bin/env python3 """Sample a browser's whole process tree once a second into a CSV. Usage: sample.py --out run.csv (--pid PID | --pid-file FILE | --name REGEX) [--mark FILE] [--mark-log FILE] [--until-gone] Each row: time, the current mark (the phase the driver is in), process count, PSS of the tree (MB, from /proc//smaps_rollup), CPU of the tree (% of one core, from utime+stime in /proc//stat), the GPU's busy % (whole card, averaged over ten reads a second), the card's VRAM in use (whole card), and the tree's own GPU use from the DRM fdinfo of its processes (amdgpu: gfx engine busy %, VRAM and GTT held by its DRM clients). The tree is every process matching --pid / --pid-file / --name plus all their descendants, found again each second, so helper processes (renderers, GPU, network) that come and go are counted. The mark comes from --mark (a file holding the label) or --mark-log (the last `MARK