0

I want to see the resources an executable uses when I run it from a command prompt/powershell.

Ideally it would be great to have a tool that does something like this straight from the command prompt:

./myexecutable -arg1 -arg2 --trackperformance
cpu usage: 12%
memory usage: 1MB
I did read stuff about performance monitor but it doesn't seem to be able to track what I want (cpu usage, memory usage overall for the specific executable that I will run).

Any ideas of a tool or command built into the command line that does this? For the windows OS?

0

On Windows, it might help to install the Windows Subsystem for Linux WSL, or install Process Explorer and Process Monitor from the Microsoft Sysinternals toolsuite.

On Linux, you can use pidstat (from the sysstat package) to track cpu- and memory usage of specific processes.

  • For instance, open an ebook in an ebook reader. (this is a long-running, single-instance process)
  • open a terminal window and type pidstat -p $(pgrep -f .epub) 1
  • scroll the ebook little bit to give the cpu some work to do

I get this output

pidstat -p $(pgrep -f .epub) 1 

Linux 4.15.0-66-generic (xx)    11/14/2019  _x86_64_    (4 CPU)  

12:18:10 PM   UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
12:18:11 PM  1000     36636    0.00    0.00    0.00    0.00    0.00     3  ebook-viewer
12:18:12 PM  1000     36636    0.00    0.00    0.00    0.00    0.00     3  ebook-viewer
12:18:13 PM  1000     36636    2.00    0.00    0.00    0.00    2.00     1  ebook-viewer
12:18:14 PM  1000     36636    2.00    2.00    0.00    2.00    4.00     3  ebook-viewer
12:18:15 PM  1000     36636   14.00    1.00    0.00    1.00   15.00     3  ebook-viewer
12:18:16 PM  1000     36636   35.00    2.00    0.00    2.00   37.00     0  ebook-viewer
12:18:17 PM  1000     36636    2.00    0.00    0.00    1.00    2.00     0  ebook-viewer
12:18:18 PM  1000     36636    5.00    1.00    0.00    1.00    6.00     3  ebook-viewer
12:18:19 PM  1000     36636    1.00    0.00    0.00    1.00    1.00     0  ebook-viewer

Average:     1000     36636    5.82    0.55    0.00    0.91    6.36     -  ebook-viewer

For short-running processes, and for displaying memory consumption, issue this command:

pidstat -r 1 -e /usr/bin/python2.7 /usr/bin/ebook-viewer /home/knb/Dropbox/books/howlinuxworks.epub

This gives you this output (note %MEM column) :

12:29:01 PM   UID       PID  minflt/s  majflt/s     VSZ     RSS   %MEM  Command
12:29:02 PM  1000     43888  23400.00      0.00 2220516  151964   0.62  python2.7
12:29:03 PM  1000     43888  12027.00      0.00 2397208  193584   0.78  python2.7
12:29:04 PM  1000     43888   4562.00      0.00 2478048  197148   0.80  python2.7
12:29:05 PM  1000     43888   3808.00      0.00 2496188  211120   0.86  python2.7
12:29:06 PM  1000     43888    186.00      0.00 2496264  212072   0.86  python2.7
12:29:07 PM  1000     43888      0.00      0.00 2496264  211752   0.86  python2.7
12:29:08 PM  1000     43888     16.00      0.00 2496264  211908   0.86  python2.7
12:29:09 PM  1000     43888     29.00      0.00 2496264  211440   0.86  python2.7
|improve this answer|||||
  • Good suggestion but this is for Linux, any tools for windows? I will edit the question to specify windows OS for the question, my bad. – theBigCheese88 Nov 14 '19 at 11:26
  • @theBigCheese88 I've updated my answer with short Windows example – knb Nov 14 '19 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.