1 year ago

#75745

test-img

Develobeer

Bash - Evaluate CPU and Memory performance of a single command that run instantly

I'm writing a Bash script to evaluate time/CPU/memory performances of commands given as input to the script.

I implemented the evaluation of time by using date command, but I have issues to evaluate CPU and memory performance related to the single command. I know that I can use top command but it shows me only runtime processes.

My issue is that if I run the script by giving as input the command, I don't know previously the assigned PID to this command, and if I want to evaluate an instant command as whoami, I cannot find it when I use top command, even if I use pipe on them.

I think for commands that needs more time, I would like to calculate an average, but for commands like whoami, ls or similar instant commands, I don't have idea how I can get the CPU and memory performance for that specific instant of time.

Thank you in advance!

linux

bash

performance

memory

cpu

0 Answers

Your Answer

Accepted video resources