Skip to content
Related Articles

Related Articles

Testing Website Loading Speed in Linux Terminal
  • Last Updated : 11 Feb, 2021
GeeksforGeeks - Summer Carnival Banner

We will see How to test a website loading speed in a Linux terminal. Here a website response time (which is getting back the result) will have a great impact on user experience. Because the loading or response is very slow we will be so frustrated. Even if our site has a slow response time the user may get a bad experience.

So in this article, we will be using the Curl command. A curl is a tool used for transferring data via different protocols 

Usage Of Curl command:

  • Total time before a request received a response (time_namelookup)
  • The total time when TCP protocol was completed on a remote server (time_connect)
  • The time when file transfer was started (time_pretransfer)
  • The time the first byte was transmitted to a remote server(time_starttransfer)
  • The time used to complete the response(time_total)

So in order to test the website speed, we need Curl installed in our system.

sudo apt install curl -y

After the installation, we can now test the loading speed of a website we need. So the command to test a website is 



curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null ADDRESS

In the above command, ADDRESS can be the URL or IP address of the website we want to test 

In the above command, we used three options they are:

  • -s: this will show an error if the command fails
  • -w: this will make the curl display result of the command
  • -o: output to a file

Here in the below image, We have tested an HTTP website.

How to Test Website Loading Speed in Linux Terminal

Suppose if we want to test HTTPS sites, we want to add the following:

  • The time measured for the entire SSL communication process(time_appconnect)
  • The time measured for redirection(time_riderect)

For this, The command is below 

curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup 
Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nAppCon 
Time:\t\t%{time_appconnect}\nRedirect Time:\t\t%{time_redirect}\nPre-transfer 
Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal 
Time:\t\t%{time_total}\n' -o /dev/null ADDRESS

How to Test Website Loading Speed in Linux Terminal

So Suppose if we don’t want to execute so long command we can make it easier by creating a curl formatting file and the command line calling the file.



Here we can see how to create it. First, we should put the below command to open the file in a nano text editor,

nano ~/curl-change.txt

After this just copy and paste the line into the file after doing this just save and close your file 

time_namelookup:  %{time_namelookup}\n
time_connect:  %{time_connect}\n
time_appconnect:  %{time_appconnect}\n
time_pretransfer:  %{time_pretransfer}\n
time_redirect:  %{time_redirect}\n
time_starttransfer:  %{time_starttransfer}\n
----------\n
time_total:  %{time_total}\n

How to Test Website Loading Speed in Linux Terminal

So since we have done it easier we have to execute the command like in the below one.

curl -w "@curl-change.txt" -o /dev/null -s ADDRESS

By using this command we should replace the URL or IP Address in the place of the ADDRESS. This will run for both HTTP and HTTPS websites.  

We will attach images by running both HTTP and HTTPS website using the above script

How to Test Website Loading Speed in Linux Terminal

The below image is HTTPS website 

How to Test Website Loading Speed in Linux Terminal

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :