how can I display the time of calculation of any software operation? For example:
seq 1 5 | awk '{sum+=$1} END {print sum}'
Do you mean something like this?
$ time seq 1 5 | awk '{sum+=$1} END {print sum}'
15
real 0m0.019s
user 0m0.000s
sys 0m0.000s
Just prepend time
:
time seq 1 5 | awk '{sum+=$1} END {print sum}'
Output:
15
real 0m0.063s
user 0m0.076s
sys 0m0.030s
You can use time
command:
$ time seq 1 5 | awk '{sum+=$1} END {print sum}'
Time is a complex entity, with many possible answers. Do you want the amount of time the CPU was blocked? The amount of time the process was alive? The amount of time the user had to wait for an answer? Or some other meaning of time altogether.
Usually you can get what you need from the POSIX time utility.
time { seq 1 5 | awk … }
real 0m0.005s
user 0m0.002s
sys 0m0.003s
real is the total time elapsed.
user is the amount of CPU time spent outside the kernel. (User mode CPU time.)
sys is the amount of CPU time spent within the kernel.
There is a more complete explanation at What do 'real', 'user' and 'sys' mean in the output of time(1)?