4

I would like to run a process from bash in Cygwin so that I have some short summary after execution like peak memory usage or average CPU usage, like time but with more information.

Are there any options?

1 Answers1

4

You can do this by running the command inside GNU time. By default, time shows you the real (wall clock), user (CPU-seconds used in user mode), and sys (CPU-seconds used in kernel mode) data items. However, you can also ask it to measure other things, such as RAM and disk usage:

/usr/bin/time -f "File system outputs: %O\nMaximum RSS size: %M\nCPU percentage used: %P" <command>

where <command> is replaced by the command you wish to run. The output will be something like:

File system outputs: 18992
Maximum RSS size: 40056
CPU percentage used: 367%

where "CPU percentage used" is a percentage and shows here that 3.6 cores were used, "Maximum RSS size" is as close as it gets to "maximum memory used" and is expressed in kilobytes, and "File system outputs" is expressed in number of operations (i.e., it does not say how much data is written). The du and df commands you gave should help there.

Note: you need to use /usr/bin/time rather than just time, as many shells have that as a builtin, which doesn't necessarily support the -f option.

For more information, see man time

https://unix.stackexchange.com/a/331707/213127

Same goes for Cygwin: there is a bash built-in which can be substituted by GNU time.