示例:
curl -o /dev/null -s -w "time_namelookup:%{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "https://www.baidu.com/"
输出:
time_namelookup: 0.005252
time_connect: 0.014415
time_starttransfer: 0.051369
time_total: 0.051625
上面这条命令及返回结果可以这么理解:
time_namelookup: DNS 服务器域名解析的时间(以上时间单位都是s) 。
time_connect: client 发出请求,到 c/s 建立TCP 的时间;里面包括 DNS 解析的时间 。
time_starttransfer: client 发出请求;到 server 响应发出第一个字节开始的时间;包括前面的2个时间 。
time_total: 从请求发起到链接关闭的总耗时。
curl 命令参数解释:
- -o: 把curl 返回的html、js 写到垃圾回收站[ /dev/null]
- -s: 去掉所有状态
- -w: 按照后面的格式写出rt
time_namelookup
: DNS 解析时间,从请求开始到 DNS 解析完毕所用时间,单位为秒,如果测试的地址为IP,这里耗时即为0
time_commec
t: client 和 server 端建立 TCP 连接的时间,连接时间,从开始到建立TCP连接完成所用时间,包括前边DNS解析时间,如果需要单纯的得到连接时间,用这个 time_connect 时间减去前边time_namelookup
时间
time_starttransfer
: 从 client 发出请求;到 web server 响应第一个字节的时间
time_total
: client 发出请求;到 web server 发送回所有的相应数据的时间
http_code
: http状态码,如200成功,301重定向,404资源未找到,500服务器错误等
网友评论