curl 查看一个web站点的响应时间(rt)

1. curl 查看web站点rt

curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"
" "http://www.taobao.com"  
02.0.014::0.015::0.018::0.019::1516256.00  

2. curl的参数

  • -o:把curl 返回的html、js 写到垃圾回收站[ /dev/null]
  • -s:去掉所有状态
  • curl -o /dev/null -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"
    " "http://www.taobao.com"   
    02.  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current  
    03.                                 Dload  Upload   Total   Spent    Left  Speed  
    04.100 28774    0 28774    0     0  1145k      0 --:--:-- --:--:-- --:--:-- 7550k  
    05.0.014::0.016::0.020::0.025::1173060.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

3. 上面时间rt的理解【单位是 秒】

  1. 0.014: DNS 服务器解析www.taobao.com 的时间单位是s   
  2. 0.015: client发出请求,到c/s 建立TCP 的时间;里面包括DNS解析的时间  
  3. 0.018: client发出请求;到s响应发出第一个字节开始的时间;包括前面的2个时间  
  4. 0.019: client发出请求;到s把响应的数据全部发送给client;并关闭connect的时间  
  5. 1516256.00 :下周数据的速度  
  6.   
  7. 1. 建立TCP连接到server返回client第一个字节的时间:0.018s - 0.015s = 0.003s  
  8. 2. server把响应数据发送给client的时间:0.019s - 0.018 = 0.01s  
原文地址:https://www.cnblogs.com/fengjian2016/p/5480694.html