Sometimes you need to track execution time for some apps for benchmarking, time command is a handy tool. Let say you have wrote few scripts trying to grep some info from some log files, each of the scripts uses different techniques or command combos. You can run your scripts along with time command, and compare their’s execution time.
Let’s assume you have written two script name script1.sh and script2.sh. You can do this
Same thing to script2.sh, and the results will looks as bellow:
real 0m1.005s user 0m0.000s sys 0m0.008s
real shows you the execution time script1.sh takes, o minutes 1.005 seconds. user and sys tracks the CPU processing time. From the results, shows us that script1.sh uses 8 milliseconds CPU processing time in kernel mode (sys) and None in user mode.