命令:bash
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解析時間
app
time_connect:TCP 鏈接創建的時間,就是三次握手的時間
curl
time_appconnect:SSL/SSH 等上層協議創建鏈接的時間,好比 connect/handshake 的時間
ide
time_redirect: 從開始到最後一個請求事務的時間
url
time_pretransfer:從請求開始到響應開始傳輸的時間
spa
time_starttransfer: 從請求開始到第一個字節將要傳輸的時間
命令行
time_total:此次請求花費的所有時間orm
示例:
事務
# 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