While testing an application's efficiency or comparing different algorithms to solve a given problem, the execution time taken is very critical. A good algorithm should execute in a minimum amount of time. Let's see how to calculate the execution time.
To measure the execution time, just prefix
time
to the command you want to run.For example:
$ time COMMAND
The command will execute and its output will be shown. Along with the output, the
time
command appends the time taken instderr
. An example is as follows:$ time ls test.txt next.txt real 0m0.008s user 0m0.001s sys 0m0.003s
It will show real, user, and system times for execution.