While I'm aware of commands such as top
(with a number of equivalents listed here), I'm not clear on how to capture the CPU usage of a "short-lived" process. For example, if I wanted to see the performance of the ls
command, what could I do that would sample the load measurement frequently enough and fast enough to be of use?
Most existing answers I've seen on this topic use a loop that repeats something like top
every n seconds, which isn't applicable for quick / short-lived commands, especially given that I won't have time to see the PID in time to feed it to said techniques. I might be able to use something from this answer since it seems to be sampling at pretty low timescales, but I suspect there's a more direct / less intense approach.