命令:
curl -w "@curl-format.txt" -o /dev/null -s -L "https://www.jd.com"
格式:
# cat curl-format.txt time_namelookup: %{time_namelookup}\n time_connect: %{time_connect}\n time_appconnect: %{time_appconnect}\n time_redirect: %{time_redirect}\n time_pretransfer: %{time_pretransfer}\n time_starttransfer: %{time_starttransfer}\n ----------\n time_total: %{time_total}\n
time_namelookup: DNS解析時間
time_connect:TCP 連接建立的時間,就是三次握手的時間
time_appconnect:SSL/SSH 等上層協議建立連接的時間,比如 connect/handshake 的時間
time_redirect: 從開始到最後一個請求事務的時間
time_pretransfer:從請求開始到響應開始傳輸的時間
time_starttransfer: 從請求開始到第一個字節將要傳輸的時間
time_total:這次請求花費的全部時間
示例:
# curl -w "@curl-format.txt" -o /dev/null -s -L "https://www.jd.com" time_namelookup: 0.529108 time_connect: 0.688685 time_appconnect: 1.201098 time_redirect: 0.000000 time_pretransfer: 1.201304 time_starttransfer: 1.418342 ---------- time_total: 1.540865
DNS查詢時間:0529108
TCP連接時間: time_connect - time_namelookup = 0.688685 - 0.529108 = 159ms
服務器處理時間:time_starttransfer - time_pretransfer = 1.418342 - 1.201304 = 217ms
內容傳輸時間:time_total - time_starttransfer = 1.540865 - 1.418342 = 122ms
命令行指定格式
# curl -w "%{time_namelookup}\n%{time_connect}\n%{time_pretransfer}\n%{time_starttransfer}\n%{time_total}" -o /dev/null -s -L "https://www.jd.com" 0.014314 0.018578 0.044222 0.293051 0.701479