Time is the essential parameter to evaluate the efficiency or performance of any task. Such a good processor is judged by good processing speed which is evaluated on the basis of time. Similarly, in Linux, the “time” command is used to evaluate the processing time taken by different commands in their execution. There are different ways to do the same task, for example, we can edit the text files using the vim editor as well as the nano editor, with the help of the time command we can evaluate which editor takes less execution time, then we can use that editor for text editing purposes for better performance.
In Linux, the time command is used to determine the execution time taken by the processor to execute the specified command.
The general syntax of using the time command:
The explanation to the above syntax is:
For example, we execute a command which will take 4 seconds execution time and determine its time using the “time” command:
The output displayed that the command was executed in 4.002 seconds, there are three types of values in the output real, user, and sys, the explanation to them is as:
We can also add an option by adding a flag of “-p”, that will display the time in portable POSIX format, to understand it, again run the above command using the “-p” flag:
We will update the repository of the Linux and will monitor the time of update by using the time command:
It will take some time to update the repository:
It takes 36.289 seconds to update the packages repository. To understand more about the time command, we can run the help using the command:
If we want that the output of the time command is not displayed on the screen, instead of that it should be saved in the text file we can run the following command:
Note: We will use the “/usr/bin/time” instead of the “time” command because the shell built-in time command does not support the “-o” option.
To view the output of the file “output.txt”, use the command:
To have the detailed summary of the executed time, use the option “-v” with the “/usr/bin/time” command:
The above figure displays the detailed summary of the executed time for the command. In the last, Linux provides the manuals of all the built-in commands, to view the manual of the time command to seek some information, use:
The time command is used in Linux for testing purposes; it is used to test the performance of newly created applications. In this write-up, we have discussed the use of the time command in Linux that is used to monitor the execution time of the commands in Linux. We have discussed two syntaxes, the built-in “time” command and “/usr/bin/time” command with its different options.
I’m an Engineering graduate and my passion for IT has brought me to Linux. Now here I’m learning and sharing my knowledge with the world.
Adblock