直接来命令
curl -o /dev/null -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" url
执行结果如下
# curl -o /dev/null -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://127.0.0.1/webmail/login/login.do % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 22157 0 22157 0 0 597k 0 --:--:-- --:--:-- --:--:-- 618k 0.000::0.000::0.031::0.036::611919.000
也可以加上 -s 参数去掉所有状态
# curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" http://172.16.0.8/webmail/login/login.do 0.002::0.002::0.048::0.056::395738.000
参数说明
-w:按照后面的格式写出rt
time_namelookup:DNS 解析域名[www.taobao.com]的时间
time_commect:client和server端建立TCP 连接的时间
time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间
time_total:client发出请求;到web的server发送会所有的相应数据的时间
speed_download:下周速度 单位 byte/s
1. 建立TCP连接到server返回client第一个字节的时间:time_starttransfer - time_commect
2. server把响应数据发送给client的时间:time_total - time_starttransfer