Curl
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 https://www.linuxandotherhstuff.com/
Output:
Lookup Time: 0.269010
Connect Time: 0.467855
Pre-transfer Time: 0.840017
Start-transfer Time: 1.141663
Total Time: 2.014788
A brief explanation of each option is shown below:
time_connect – Display the time in seconds from the connect was noticed by curl until the first byte arrived.
time_namelookup – Display the time in seconds it took from the start until the name resolving was completed.
time_pretransfer – Display the time in seconds it took from the start until the file transfer was just about to begin.
time_starttransfer – Display the time in seconds from the connect was noticed by curl until the first byte arrived.
time_total – The total time in seconds to perform the operation.
-s – Don’t display the progress bar.
-w – Used to define what to display on output.
-o – Used to write complete output to /dev/null.
If your website is HTTPS, you can run the following command:
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 https://www.linux.com
You should get the following output:
Testing Website Response Time for :https://www.linux.com/
Lookup Time: 5.463834
Connect Time: 5.529342
AppCon Time: 5.772415
Redirect Time: 0.000000
Pre-transfer Time: 5.772548
Start-transfer Time: 5.809385
Total Time: 6.100520
Testing Website Response Time for :https://www.howtoforge.com/
Lookup Time: 0.511
Connect Time: 0.564
AppCon Time: 0.724
Redirect Time: 0.000
Pre-transfer Time: 0.724
Start-transfer Time: 1.085
Total Time: 1.264
If you don’t want to run a long command every time, you can create a file named curl_test.txt and all required options:
nano curl_test.txt
Add the following lines:
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
Save and close the file then run the following command:
curl -w “@curl_test.txt” -o /dev/null -s https://www.howtoforge.com
You should get the following output:
time_namelookup: 0.013
time_connect: 0.056
time_appconnect: 0.160
time_pretransfer: 0.160
time_redirect: 0.000
time_starttransfer: 0.511
time_total: 0.753