curl调用

1. curl 查看web站点rt

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




2. curl的参数

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



使用json调用

curl -i -X POST -H 'content-type: application/json' -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n"  -d '{json内容}' url



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章