1. curl 查看web站點rt
- curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" "http://www.taobao.com"
- 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}"\n" "http://www.taobao.com"
- % Total % Received % Xferd Average Speed Time Time Time Current
- Dload Upload Total Spent Left Speed
- 100 28774 0 28774 0 0 1145k 0 --:--:-- --:--:-- --:--:-- 7550k
- 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的理解【單位是 秒】
- 0.014: DNS 服務器解析www.taobao.com 的時間單位是s
- 0.015: client發出請求,到c/s 建立TCP 的時間;裏面包括DNS解析的時間
- 0.018: client發出請求;到s響應發出第一個字節開始的時間;包括前面的2個時間
- 0.019: client發出請求;到s把響應的數據全部發送給client;並關閉connect的時間
- 1516256.00 :下載數據的速度
- 1. 建立TCP連接到server返回client第一個字節的時間:0.018s - 0.015s = 0.003s
- 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