Maximum memory consumption in linux bash using openssl with aes

3
#!/bin/sh
SUM = 0
for i in {1..5}
do
t=$((/ usr / bin / time-f '% e' openssl enc -aes-128-ecb -K 1234567890 -in t -out g 1> /dev/null) 2> &1)
SUM = 'bc <<<" $ SUM + $ t "'
done
res = bc <<< "scale = 4; $ SUM / 5"
echo $res

The above code shows the average time of the 5 replicates of openssl using the AES cipher. Getting the same idea, how can I get maximum memory consumption?

    
asked by anonymous 27.04.2018 / 15:30

1 answer

5

You might be able to do what you want by using the time(1) command. According to the man page of the command it supports format strings with specific functionality to report memory usage:

  

Memory

     

% M Maximum resident set of the process during its lifetime,                 in Kbytes.

     

% t (Not in tcsh (1).) Average resident set size of the process,                 in Kbytes.

     

% K Total average (data + stack + text) memory use of the process, in                 Kbytes.

Either way I recommend looking at the question Unix command to tell you how much RAM was used during the program's runtime? (in English) of our Unix & Linux because they do a good job of explaining how memory works in Linux and explains why it's too difficult (or even impossible) to accurately measure what you want.

    
27.04.2018 / 16:48