原文:https://josephscott.org/archives/2011/10/timing-details-with-curl/)
第一步:创建一个新文件,curl-format并粘贴:
vim curl-format
\n
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
\n
第二步,请求
curl -w "@/root/curl-format" -o /dev/null -s https://www.baidu.com
-w "@curl-format" 告诉cURL使用我们的格式文件
-o /dev/null 将请求的输出重定向到/dev/null
-s 告诉cURL不要显示进度表
curl 获取HTTP返回的状态码
https://www.baidu.com是我们要求的URL
返回的状态:
time_connect: 0.080
time_appconnect: 0.398
time_pretransfer: 0.398
time_redirect: 0.000
time_starttransfer: 0.571
time_total: 0.571