1、直接訪問使用:
curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} www.baidu.com

輸出變量需要按照%{variable_name}的格式,如果需要輸出%,double一下即可,即%%,同時,\n是換行,\r是回車,\t是TAB。
-w 指定格式化文件
-o 請求重定向到,不帶此參數則控制台輸出返回結果
-s 靜默,不顯示進度
2、定義時間格式化文件訪問
#vim curl-time.txt \n http: %{http_code}\n dns: %{time_namelookup}s\n redirect: %{time_redirect}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_starttransfer: %{time_starttransfer}s\n size_download: %{size_download}bytes\n speed_download: %{speed_download}B/s\n ----------\n time_total: %{time_total}s\n \n
curl -w "@curl-time.txt" https://www.sogou.com/websearch/api/getcity

curl的部分時間等變量注釋:
time_total 總時間
time_namelookup DNS解析時間
time_connect 連接時間
time_appconnect 連接建立完成時間
time_pretransfer 從開始到准備傳輸的時間
time_redirect 重定向時間
time_starttransfer 開始傳輸時間
文章參考:
https://blog.csdn.net/hqzxsc2006/article/details/50547684
https://blog.csdn.net/weifangan/article/details/80741981
