Calculating and reducing the runtime of a script

In this article, we are going to learn how to calculate and reduce the script’s runtime. A simple time command will help in calculating the execution time.


Besides having a terminal open, make sure you have the necessary scripts present in your system.

Write script

Now, we will write a simple script that contains a few commands, and then, using the time command, we will get the runtime of that script. Create a script and write the following code in it.

ls -l 
sudo apt install python3

How script works

Now, we have written a script and four commands in that script: clear, ls, date, and a python3 installation command. Run your script as follows:

$ time bash

After the execution, you will get the runtime of the script at the bottom of your output.


Submit a Comment

Your email address will not be published. Required fields are marked *

Related Articles