Curl Command To Measure DNS And Network Timing
The curl command line tool has a reporting option which you can use to measure different bits of timing in the network handling. This can be useful to monitor or investigate network issues:
curl -s --connect-timeout 5 \
-w "time_namelookup: %{time_namelookup}, time_connect: %{time_connect}, time_appconnect: %{time_appconnect}, time_pretransfer: %{time_pretransfer}, time_redirect: %{time_redirect}, time_starttransfer: %{time_starttransfer}, time_total: %{time_total}\n" \
-o /dev/null \
https://www.kaper.com/
Code language: Bash (bash)
Example output:
$ curl -s --connect-timeout 5 -w "time_namelookup: %{time_namelookup}, time_connect: %{time_connect}, time_appconnect: %{time_appconnect}, time_pretransfer: %{time_pretransfer}, time_redirect: %{time_redirect}, time_starttransfer: %{time_starttransfer}, time_total: %{time_total}\n" -o /dev/null https://www.kaper.com/
time_namelookup: 0,372554, time_connect: 0,389102, time_appconnect: 0,433429, time_pretransfer: 0,433522, time_redirect: 0,000000, time_starttransfer: 0,739809, time_total: 0,837366
Code language: Bash (bash)
You can also insert \n’s in the option to put the result on multiple lines:
$ curl -s --connect-timeout 5 -w "time_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_redirect: %{time_redirect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" -o /dev/null https://www.kaper.com/
time_namelookup: 0,003033
time_connect: 0,018615
time_appconnect: 0,059657
time_pretransfer: 0,059775
time_redirect: 0,000000
time_starttransfer: 0,222467
time_total: 0,292495
Code language: Bash (bash)