Como gerar estatísticas do processo após a conclusão?

2

Eu gostaria de executar um processo de bash no Cygwin para que eu tenha um pequeno resumo após a execução, como o uso de pico de memória ou o uso médio da CPU, como time , mas com mais informações.

Existe alguma opção?

    
por Euri Pinhollow 19.02.2017 / 10:04

1 resposta

2

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

link

O mesmo vale para o Cygwin: existe um bash embutido que pode ser substituído pelo tempo GNU.

    
por 19.02.2017 / 16:12